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

feat: add network settings screen #701

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

pedroferreira1
Copy link
Member

@pedroferreira1 pedroferreira1 commented Dec 3, 2024

Acceptance Criteria

  • Improve change server screen to a Network Settings screen
    • Refactor storage to save an object with network settings instead of saving separately txMining, network and server.
    • Allow user to change all possible URLs in a single place.

Version migration:

All users will start this new version on mainnet. I think this is ok and doesn't hurt anyone, since it's really easy to change networks now.

Screen.Recording.2024-12-02.at.23.03.15.mov

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.

Comment on lines -158 to -161
config.setServerUrl(serverUrl);
config.setNetwork(networkName);
LOCAL_STORE.setServers(serverUrl);
LOCAL_STORE.setNetwork(networkName);
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: We used to re-set the lib config and local storage to avoid issues with hardware wallets and wallet resets while on testnet ( #537, #547 )

I feel we may have a regression error by not setting those values here. Was this context tested?

Comment on lines +127 to 134
let networkSettings = LOCAL_STORE.getNetworkSettings();
if (!networkSettings) {
// If it doesn't exist in the store, it's a fresh install
// or a migration from older versions, so we just use the
// default network from the lib
const libDefaultNetwork = hathorLib.config.getNetwork().name;
networkSettings = NETWORK_SETTINGS[network];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

suggestion(non-blocking): We have two instances of this same code. It could be nice to have something like a safeGetNetworkSettings(), and it feels to me that it could be on the LOCAL_STORE or even on this helpers file.

@@ -97,7 +97,8 @@ const wallet = {
* @return {boolean} boolean indicating if address is valid
*/
validateAddress(address) {
const networkName = LOCAL_STORE.getNetwork() || 'mainnet';
const networkSettings = LOCAL_STORE.getNetworkSettings();
const networkName = networkSettings ? networkSettings.network : 'mainnet';
Copy link
Collaborator

Choose a reason for hiding this comment

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

thought(non-blocking): This could also be benefited by this "safeGet" suggestion.

Comment on lines +64 to +69
NETWORKSETTINGS_REQUEST_UPDATE: 'NETWORKSETTINGS_REQUEST_UPDATE',
NETWORKSETTINGS_UPDATE: 'NETWORKSETTINGS_UPDATE',
NETWORKSETTINGS_SET_STATUS: 'NETWORKSETTINGS_SET_STATUS',
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
NETWORKSETTINGS_REQUEST_UPDATE: 'NETWORKSETTINGS_REQUEST_UPDATE',
NETWORKSETTINGS_UPDATE: 'NETWORKSETTINGS_UPDATE',
NETWORKSETTINGS_SET_STATUS: 'NETWORKSETTINGS_SET_STATUS',
NETWORKSETTINGS_UPDATE_REQUESTED: 'NETWORKSETTINGS_UPDATE_REQUESTED',
NETWORKSETTINGS_UPDATED: 'NETWORKSETTINGS_UPDATED',
NETWORKSETTINGS_SET_STATUS: 'NETWORKSETTINGS_SET_STATUS',

Comment on lines +81 to +91
if (networkSettings.status === NETWORK_SETTINGS_STATUS.LOADING) {
setLoading(true);
}

if (networkSettings.status === NETWORK_SETTINGS_STATUS.ERROR) {
setErrorMessage(networkSettings.error)
setLoading(false);
}

if (networkSettings.status === NETWORK_SETTINGS_STATUS.READY) {
setLoading(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you really need to set state here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress (WIP)
Development

Successfully merging this pull request may close these issues.

3 participants