-
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.
feat(TokenEnterAmount): add new component to Swap flow (#6247)
Final PR for new Enter Amount component. This page implements a 2nd version of SwapScreen that uses new Enter Amount component. It is hidden behind the feature flag to mitigate the risks of such a big rework. `SwapScreenV2.test.tsx` file is an exact copy of the existing `SwapScreen.test.tsx`. It seems like a huge addition (2k lines) BUT it is a 99% copy-paste just because the new flow is implemented as a new component. The only changes in that file are `testID` props and some translations excerpts. To make life A LOT easier in reviewing this specific file, I suggest doing the following in VSCode to only see the changed lines: - Right click `SwapScreen.test.tsx` and click "Select for Compare" - Right click `SwapScreenV2.test.tsx` and click "Compare with Selected" Details of the implementation for clarity: - The correct functioning of the new component has been ensured by implementing it to pass all the existing tests from `SwapScreen.test.tsx`. - Removed local Redux slice. As a new Enter Amount component is using `useState` and it would be a mess to keep multiple `useState`s and Redux slice in sync - all the other fields from the slice were moved to the corresponding `useState`s. - The business logic of the component is intact. Only the state implementation (useState instead of Redux slice) has changed to follow the existing logic therefore some functions look different but they do identical things in terms of business logic. - Code has been order in the following order: 1. variables 2. derived variables (`useMemo`) 3. `useEffect`s 4. functions ### Test plan <video width="400" src="https://github.com/user-attachments/assets/51811584-1eec-404d-9ec3-b67d5aaab79d"></video> ### Related issues Relates to RET-1208 ### Backwards compatibility Yes ### Network scalability If a new NetworkId and/or Network are added in the future, the changes in this PR will: - [x] Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)
- Loading branch information
Showing
11 changed files
with
3,300 additions
and
107 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
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
Oops, something went wrong.