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

(15) refactor: network settings actions #360

Merged
merged 23 commits into from
Nov 1, 2023
Merged

Conversation

alexruzenhack
Copy link
Contributor

@alexruzenhack alexruzenhack commented Oct 24, 2023

This PR aims to improve the Network Settings Actions by decomposing it in actions that conveys a better semantic.

Acceptance Criteria

  • rename action to NETWORKSETTINGS_UPDATE_REQUEST
  • add action NETWORKSETTINGS_UPDATE_STATE
  • add action NETWORKSETTINGS_PERSIST_STORE
  • add action NETWORKSETTINGS_UPDATE_WAITING
  • refactor action NETWORKSETTINGS_UPDATE_SUCCESS
  • refactor action NETWORKSETTINGS_UPDATE_INVALID
  • refactor action NETWORKSETTINGS_UPDATE_FAILURE
  • add docstring to action NETWORKSETTINGS_UPDATE_READY
  • refactor NetworkStatusBar
  • refactor saga effect persistNetworkSettings
  • resolve all the lint issues

Warning

The following video has a legacy behavior when showing the network status bar alert for mainnet settings when removing only the wallet service URLs fields. This bar should show up only if the required fields diverges from the what is set to be the mainnet. You find the video with the correct behavior after this one.

ds-action-refactoring-clip.mp4

Correct behavior regarding network status bar:

ds-action-refactoring-rv1-clip.mp4

Closes: #358

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@alexruzenhack alexruzenhack self-assigned this Oct 24, 2023
@alexruzenhack alexruzenhack marked this pull request as ready for review October 24, 2023 18:43
@alexruzenhack alexruzenhack changed the title refactor: network settings actions (15) refactor: network settings actions Oct 24, 2023
Base automatically changed from feat/ds-alert-ui to dev October 27, 2023 13:07
- This action replaces the NETWORK_UPDATE_ERRORS
- Improve readability
- change network settings status to `WAITING` just after persist the
  custom network settings
- throw a fatal exception message to the user if the wallet is not found
- stop the wallet and clean its storage and addresses
- add a reducer for RELOAD_WALLET_REQUESTED action to clean the tokens
  history and balance on redux store
src/screens/NetworkSettings/CustomNetworkSettingsScreen.js Outdated Show resolved Hide resolved
src/screens/NetworkSettings/helper.js Outdated Show resolved Hide resolved
src/sagas/helpers.js Outdated Show resolved Hide resolved
src/screens/NetworkSettings/CustomNetworkSettingsScreen.js Outdated Show resolved Hide resolved
src/sagas/helpers.js Outdated Show resolved Hide resolved
src/components/NetworkSettings/NetworkStatusBar.js Outdated Show resolved Hide resolved
src/actions.js Outdated Show resolved Hide resolved
src/reducers/reducer.js Show resolved Hide resolved
src/reducers/reducer.js Show resolved Hide resolved
src/screens/NetworkSettings/CustomNetworkSettingsScreen.js Outdated Show resolved Hide resolved
src/sagas/networkSettings.js Outdated Show resolved Hide resolved
src/sagas/networkSettings.js Show resolved Hide resolved
src/sagas/networkSettings.js Show resolved Hide resolved
- The full check will happen when the custom network contain a valid URL
  for wallet-service. This behavior is to avoid a bypass on the network
  status bar when the wallet-service is given. This is important because
  the wallet-service has precedence over fullnode.
const networkSettings = useSelector((state) => state.networkSettings);
if (eq(networkSettings, PRE_SETTINGS_MAINNET)) {
return null;
function notMainnet(networkSettings) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method deserves a comment explaining why you split the validation in two.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: f31c263

Comment on lines 43 to 46
if (status === NETWORKSETTINGS_STATUS.WAITING) {
yield put(networkSettingsUpdateSuccess());
} else {
yield put(networkSettingsUpdateReady());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this deserves a comment explaining these state changes and why they happen here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added: 3825b2e

src/actions.js Outdated
@@ -120,11 +120,22 @@ export const types = {
// NOTE: These actions follows a taxonomy that should be applied
// to all other actions.
// See: https://github.com/HathorNetwork/hathor-wallet-mobile/issues/334
NETWORKSETTINGS_UPDATE: 'NETWORK_SETTINGS_UPDATE',
/* It delivers the user's network settings input from the form. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* It delivers the user's network settings input from the form. */
/* It initiates an update of the network settings based on user input from a form. */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: d994fdb

src/actions.js Outdated
NETWORKSETTINGS_PERSIST_STORE: 'NETWORKSETTINGS_PERSIST_STORE',
/* It indicates the persistence is complete and the wallet will be reloaded. */
NETWORKSETTINGS_UPDATE_WAITING: 'NETWORKSETTINGS_UPDATE_WAITING',
/* It indicates the update is complete after wallet reloads. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* It indicates the update is complete after wallet reloads. */
/* It indicates the update is complete after the wallet reloads. */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: d994fdb

src/actions.js Outdated
Comment on lines 915 to 916
* Emits the waiting signal after persist the custom network.
* It means the wallet will reload.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Emits the waiting signal after persist the custom network.
* It means the wallet will reload.
* Action indicating that the network settings update process is in a waiting state.
* This is used after persisting custom network configurations, resulting in a wallet reload.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: d994fdb

src/actions.js Outdated
Comment on lines 923 to 924
* Emits the success signal after wallet reloads.
* It servers as hook for the frontend to provide feedback for the user.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Emits the success signal after wallet reloads.
* It servers as hook for the frontend to provide feedback for the user.
* Action indicating that the network settings update was successful
* This serves as a hook for the frontend to provide feedback to the user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea here (and in the previous comments) is that the action by itself does not emit anything, somewhere else is dispatching this action

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: d994fdb

src/actions.js Outdated
Comment on lines 940 to 941
* Emits invalid signal for custom network settings request inputs.
* It means the form should present the invalid message on the corresponding inputs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Emits invalid signal for custom network settings request inputs.
* It means the form should present the invalid message on the corresponding inputs.
* Action indicating an invalid state for the custom network settings request inputs.
* Intended to trigger the presentation of invalid messages on the corresponding form inputs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved: d994fdb

@alexruzenhack alexruzenhack merged commit a620076 into dev Nov 1, 2023
2 checks passed
@alexruzenhack alexruzenhack deleted the refactor/ds-actions branch November 1, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants