metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

fix: handle low numbers when saving default advanced gas fees

Open vinistevam opened this issue 1 year ago • 12 comments

Description

This PR aims to fix a bug when a user saves very low default values, in the example 0.000000001 number was turned into 1e-9 string and thrown when converting it down the line in the next transaction.

Related issues

Fixes: https://github.com/MetaMask/metamask-extension/issues/22605

Manual testing steps

  1. Go to send flow
  2. Edit gas fee > Advanced
  3. Change Max Base Fee 1 and Priority Fee to 0.000000001
  4. Check Save these values as my default for the <chain name> network.

I was able to reproduce the issue using Ganache with default gas zero.

Screenshots/Recordings

Before

before_fix_gas.webm

After

advance-gas.webm

Pre-merge author checklist

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

vinistevam avatar Feb 02 '24 10:02 vinistevam

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

github-actions[bot] avatar Feb 02 '24 10:02 github-actions[bot]

Builds ready [38d63f8]
Page Load Metrics (830 ± 48 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint951781242813
domContentLoaded95623168
load688101283010048
domInteractive95623168
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 418 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 02 '24 10:02 metamaskbot

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (8ab0637) 68.53% compared to head (bdaca06) 68.53%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #22790      +/-   ##
===========================================
- Coverage    68.53%   68.53%   -0.00%     
===========================================
  Files         1089     1089              
  Lines        42966    42972       +6     
  Branches     11440    11440              
===========================================
+ Hits         29446    29448       +2     
- Misses       13520    13524       +4     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Feb 02 '24 10:02 codecov[bot]

LGTM!

DDDDDanica avatar Feb 02 '24 10:02 DDDDDanica

@vinistevam Build from https://github.com/MetaMask/metamask-extension/commit/38d63f8a9cf05be24c39d1495a0236b0b7e71b96] - it won't let me type 0 after decimal point:

https://github.com/MetaMask/metamask-extension/assets/104780023/bf32a906-91f2-4b00-8574-6b5cb9a7d052

I can cut and paste 0.000000001 but it results in failed transaction.

sleepytanya avatar Feb 02 '24 16:02 sleepytanya

Builds ready [dabd239]
Page Load Metrics (861 ± 25 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint94161122199
domContentLoaded9471694
load7509638615325
domInteractive9471694
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 241 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 05 '24 12:02 metamaskbot

Builds ready [9e0a0ae]
Page Load Metrics (783 ± 19 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint88140109157
domContentLoaded9421784
load7078597833919
domInteractive9421784
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 346 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 05 '24 16:02 metamaskbot

Builds ready [49435c8]
Page Load Metrics (770 ± 19 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint86137107136
domContentLoaded9461784
load7098717704019
domInteractive9461784
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 346 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 06 '24 13:02 metamaskbot

Builds ready [01352bb]
Page Load Metrics (794 ± 27 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint92165118178
domContentLoaded105821115
load7109177945527
domInteractive105821115
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 375 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 06 '24 20:02 metamaskbot

Low values can be entered and saved correctly. Chrome 121.0.6167.139

https://github.com/MetaMask/metamask-extension/assets/104780023/5556ff20-02b5-4c6e-bd98-49d39d1f14c7

Firefox 122.0

https://github.com/MetaMask/metamask-extension/assets/104780023/10c4f4da-6a60-4b00-b1ac-edd34e8e2509

sleepytanya avatar Feb 06 '24 23:02 sleepytanya

Builds ready [4491d22]
Page Load Metrics (1235 ± 168 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1444002176531
domContentLoaded1296372512
load80920701235350168
domInteractive1296372512
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 381 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 15 '24 17:02 metamaskbot

Builds ready [728b59c]
Page Load Metrics (936 ± 76 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1252711803115
domContentLoaded970322311
load818147593615976
domInteractive970322311
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 381 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 16 '24 08:02 metamaskbot

Builds ready [bdaca06]
Page Load Metrics (1072 ± 86 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint1024292116230
domContentLoaded1595352512
load8901665107217886
domInteractive1595352512
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 381 Bytes (0.01%)
  • common: 0 Bytes (0.00%)

metamaskbot avatar Feb 19 '24 09:02 metamaskbot