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

fix(enter amount): switching empty amounts should remain empty #6297

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

kathaypacific
Copy link
Collaborator

Description

As the title

Test plan

Before: https://valora-app.slack.com/archives/C04B61SJ6DS/p1733247536281249?thread_ts=1733245811.844689&cid=C04B61SJ6DS

After: https://github.com/user-attachments/assets/5108ab1f-73d7-4941-9ad0-17bf338dd302

Related issues

Backwards compatibility

Y

Network scalability

If a new NetworkId and/or Network are added in the future, the changes in this PR will:

  • Continue to work without code changes, OR trigger a compilation error (guaranteeing we find it when a new network is added)

@@ -179,7 +179,8 @@ export function useEnterAmount(props: {
.replace(new RegExp(`[${decimalSeparator}]?0+$`), '')
: ''

const parsedTokenAmount = parseInputAmount(convertedLocalToToken, decimalSeparator)
const parsedTokenAmount =
amount === '' ? null : parseInputAmount(convertedLocalToToken, decimalSeparator)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

parseInputAmount always returns a big number and returns 0 if the convertedLocalToToken (derived from amount) is an empty string

Copy link

codecov bot commented Dec 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.01%. Comparing base (a21a900) to head (4cf6f9d).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #6297   +/-   ##
=======================================
  Coverage   89.01%   89.01%           
=======================================
  Files         739      739           
  Lines       31607    31607           
  Branches     5879     5877    -2     
=======================================
  Hits        28134    28134           
  Misses       3275     3275           
  Partials      198      198           
Files with missing lines Coverage Δ
src/components/TokenEnterAmount.tsx 94.51% <100.00%> (ø)

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a21a900...4cf6f9d. Read the comment docs.

Copy link
Member

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

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

🚀

Do we need a test to cover for this?

@kathaypacific
Copy link
Collaborator Author

🚀

Do we need a test to cover for this?

yes! @sviderock did a great job creating thorough test cases so i was able to slot in an assertion in an existing test

@kathaypacific kathaypacific added this pull request to the merge queue Dec 6, 2024
Merged via the queue into main with commit c858ab0 Dec 6, 2024
15 checks passed
@kathaypacific kathaypacific deleted the kathy/fix-swithc-amount branch December 6, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants