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(ramp): add sell quick amounts with gas estimations #8080

Merged
merged 16 commits into from
Jan 11, 2024

Conversation

wachunei
Copy link
Member

Description

This PR adds quick amounts buttons as percentages to the Sell Build Quote Keyboard. The percentages and max button will calculate a new amount Amount and always be set to the minimum of (Amount, Balance - Gas Fees) if the selected asset is the native asset, enforcing the Amount never to be over the required gas fees to be paid.

Related issues

Fixes:

Manual testing steps

  1. Go to Sell flow
  2. Select a native asset (eg: Ethereum in mainnet)
  3. Open the keyboard and test the buttons

Screenshots/Recordings

Before

After

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2023-12-12.at.14.25.46.mp4

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@wachunei wachunei added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) team-ramp issues related to Ramp features needs-ramp-qa Tickets that need feature QA on the ramps flows labels Dec 12, 2023
Copy link

socket-security bot commented Dec 12, 2023

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@consensys/on-ramp-sdk 1.25.4...1.25.6 None +0/-0 433 kB pmkowalski

@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 8 lines in your changes are missing coverage. Please review.

Comparison is base (445ef2b) 39.65% compared to head (2a83e69) 40.21%.
Report is 19 commits behind head on main.

Files Patch % Lines
...onents/UI/Ramp/buy/Views/BuildQuote/BuildQuote.tsx 77.14% 1 Missing and 7 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8080      +/-   ##
==========================================
+ Coverage   39.65%   40.21%   +0.56%     
==========================================
  Files        1233     1234       +1     
  Lines       29820    29883      +63     
  Branches     2840     2862      +22     
==========================================
+ Hits        11824    12017     +193     
+ Misses      17307    17175     -132     
- Partials      689      691       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@wachunei wachunei marked this pull request as ready for review December 12, 2023 21:36
@wachunei wachunei requested a review from a team as a code owner December 12, 2023 21:36
Copy link
Contributor

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/1046cfe8-9727-43e2-ac4c-66ebdfd9f683
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

Copy link

socket-security bot commented Dec 12, 2023

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

@wachunei
Copy link
Member Author

@SocketSecurity ignore @consensys/on-ramp-sdk@1.25.6

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

Nice feature, I really missed it and did not realise it could be added this way. Good job.

I added comments as I understood the overall code but still find it difficult to exactly get what cases we actually take into account, specifically related to gaslimit, because of the use of numbers for which I have to guess the origin instead of clearly being told what they are for.
I suggest you add some code comments to explain why and/or use explicit constant names to prevent the magic numbers that could not be obvious for other devs. Try to imagine asking yourself what these numbers would mean if you just landed on this code without any knowledge of the project or crypto.
Thanks!

@wachunei
Copy link
Member Author

@NicolasMassart Thank you for your review. I have addressed some of the comments already in the latest commit.

@bkirb
Copy link
Contributor

bkirb commented Jan 9, 2024

@wachunei LGTM I finished verifying this change ✅

@wachunei wachunei added ramp-qa-passed and removed needs-ramp-qa Tickets that need feature QA on the ramps flows labels Jan 11, 2024
wachunei and others added 2 commits January 11, 2024 14:50
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
NicolasMassart
NicolasMassart previously approved these changes Jan 11, 2024
Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

I approve this changes for merge.

However I believe we should carefully refactor the test to make sure it's very clear what all the values are and what the test case is.
Not doing it doesn't break the code but doing it would ,make the code even more easy to understand.
Please consider this suggestion before merging.

@wachunei
Copy link
Member Author

I approve this changes for merge.

However I believe we should carefully refactor the test to make sure it's very clear what all the values are and what the test case is. Not doing it doesn't break the code but doing it would ,make the code even more easy to understand. Please consider this suggestion before merging.

Done in cf91073, thank you very much for your review

Copy link
Contributor

@NicolasMassart NicolasMassart left a comment

Choose a reason for hiding this comment

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

Looks good to me.
Thank you so much, I love reading clear code like this!

@wachunei wachunei removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jan 11, 2024
Copy link

sonarcloud bot commented Jan 11, 2024

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

2 New issues
0 Security Hotspots
92.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@wachunei wachunei merged commit f22e0eb into main Jan 11, 2024
25 checks passed
@wachunei wachunei deleted the feat/ramp-sell-quick-amounts branch January 11, 2024 20:45
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2024
@metamaskbot metamaskbot added the release-7.15.0 Issue or pull request that will be included in release 7.15.0 label Jan 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ramp-qa-passed release-7.15.0 Issue or pull request that will be included in release 7.15.0 team-ramp issues related to Ramp features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants