-
Notifications
You must be signed in to change notification settings - Fork 26
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
base: master
Are you sure you want to change the base?
Conversation
c9fa052
to
fddf771
Compare
config.setServerUrl(serverUrl); | ||
config.setNetwork(networkName); | ||
LOCAL_STORE.setServers(serverUrl); | ||
LOCAL_STORE.setNetwork(networkName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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]; | ||
} |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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.
NETWORKSETTINGS_REQUEST_UPDATE: 'NETWORKSETTINGS_REQUEST_UPDATE', | ||
NETWORKSETTINGS_UPDATE: 'NETWORKSETTINGS_UPDATE', | ||
NETWORKSETTINGS_SET_STATUS: 'NETWORKSETTINGS_SET_STATUS', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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', |
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); |
There was a problem hiding this comment.
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?
ab84740
to
16265fb
Compare
Acceptance Criteria
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