You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Add a source network and destination network selector
Screenshot
PR Type
Enhancement
Description
Added a new NetworkSelector component to allow users to select source and destination networks.
Introduced a NetworkSource enum to define network types (CONSENSUS and DOMAIN).
Updated the SendTokenFormValues interface to include sender, sourceNetwork, sourceDomainId, destinationNetwork, and destinationDomainId fields.
Integrated the network selection functionality into the ActionsModal form, allowing users to specify the source and destination networks when sending tokens.
Changes walkthrough 📝
Relevant files
Enhancement
ActionsModal.tsx
Add network selection functionality to ActionsModal
Code Duplication The NetworkSelector component logic is duplicated for both source and destination network selection. Consider refactoring to use a single component instance or abstracting common functionality to reduce redundancy and improve maintainability.
Possible Bug The setNetwork and setDomainId functions are called with potentially undefined values from the network['domains'] array without null checks. This could lead to runtime errors if the array is empty or the expected properties are missing.
UI Consistency The CSS classes applied in the NetworkSelector component vary significantly between different states (e.g., selected vs. non-selected). Ensure consistent styling to maintain a uniform user interface.
Hardcoded Values The initial values for sourceNetwork and destinationNetwork are hardcoded to NetworkSource.CONSENSUS. Consider making these configurable or ensuring they are set based on user preferences or previous selections to enhance flexibility.
Use unique names for each FieldArray to avoid state management issues
The FieldArray component's name attribute is set to 'dischargeNorms' for multiple different fields, which could lead to unexpected behavior as it might mix up the state management for different fields. Each FieldArray should have a unique name reflecting its purpose.
Why: This suggestion addresses a critical issue by ensuring that each FieldArray has a unique name, which is essential for correct state management and avoiding unexpected behavior.
10
Add safe navigation to prevent potential runtime errors when network['domains'] is undefined
Consider using a more robust error handling mechanism for the network and domain ID selections. Currently, the code does not handle cases where network['domains'] might be undefined or empty, which could lead to runtime errors.
Why: This suggestion addresses a potential runtime error by adding safe navigation, which is a crucial improvement for stability and robustness.
9
Possible issue
Add dependencies to useMemo to ensure it updates when networks changes
The useMemo hook is used to memoize the first network but does not specify dependencies. This could lead to stale data being used if the networks array changes. Consider adding networks as a dependency to the useMemo hook.
Why: Adding dependencies to the useMemo hook ensures that the memoized value updates correctly when the networks array changes, preventing potential bugs related to stale data.
8
Replace hardcoded network source values with dynamic user-selected values
Replace the hardcoded 'NetworkSource.CONSENSUS' and 'NetworkSource.DOMAIN' in the onClick handlers with dynamic values based on the actual selected network. This will ensure that the correct network source is set based on user selection rather than being hardcoded, which could lead to incorrect behavior if the network context changes.
Why: The suggestion improves flexibility and correctness by using dynamic values instead of hardcoded ones. However, the exact implementation details are not fully clear from the suggestion, and it might require additional context to implement correctly.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Add a source network and destination network selector
Screenshot
PR Type
Enhancement
Description
NetworkSelector
component to allow users to select source and destination networks.NetworkSource
enum to define network types (CONSENSUS
andDOMAIN
).SendTokenFormValues
interface to includesender
,sourceNetwork
,sourceDomainId
,destinationNetwork
, anddestinationDomainId
fields.ActionsModal
form, allowing users to specify the source and destination networks when sending tokens.Changes walkthrough 📝
ActionsModal.tsx
Add network selection functionality to ActionsModal
explorer/src/components/WalletSideKick/ActionsModal.tsx
NetworkSelector
component for selecting source and destinationnetworks.
NetworkSource
enum for network types.SendTokenFormValues
to include network-related fields.ActionsModal
form.