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

Adding network status section on edit gas fee modal #12704

Merged
merged 12 commits into from
Nov 23, 2021
Merged

Conversation

jpuri
Copy link
Contributor

@jpuri jpuri commented Nov 15, 2021

Fixes: #12452

Explanation: Adding network status section on edit gas fee modal.

Screenshot 2021-11-15 at 5 38 34 AM

@jpuri jpuri requested a review from a team as a code owner November 15, 2021 04:04
@github-actions
Copy link
Contributor

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.

@metamaskbot
Copy link
Collaborator

Builds ready [07a365d]
Page Load Metrics (822 ± 24 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint122853444212102
domContentLoaded7229498215124
load7259498225024
domInteractive7229498215124

highlights:

storybook

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Nice work, just had some comments/suggestions.

@metamaskbot
Copy link
Collaborator

Builds ready [a968d77]
Page Load Metrics (779 ± 23 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint29380338816981
domContentLoaded7129327784924
load7139327794923
domInteractive7129327784924

highlights:

storybook

@jpuri jpuri requested a review from mcmire November 16, 2021 18:37
@jpuri jpuri added this to the EIP 1559 V2 milestone Nov 16, 2021
<div className="network-status__info-field">
<span className="network-status__info-field-data">
{gasFeeEstimates?.estimatedBaseFee &&
`${gasFeeEstimates?.estimatedBaseFee} GWEI`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be getting converted to GWEI? I am seeing 0.000000009 GWEI locally. Also according to the designs should we completely round this number to prevent the number from wrapping?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep I also see that locally for test network, but as I understand gasFeeEstimates?.estimatedBaseFee is already in GWEI, thus I guess it is only a test network thing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. That's odd.

Copy link
Contributor Author

@jpuri jpuri Nov 18, 2021

Choose a reason for hiding this comment

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

the values looks odd to you ?

in test networks I noticed it varies from .00000009 to something like 213.2342353, not sure what the reason is

Copy link
Contributor

@mcmire mcmire Nov 18, 2021

Choose a reason for hiding this comment

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

Oh I see. I just wouldn't expect gas fees to be lower than 1 GWEI at all, but if it is sometimes higher then I guess it's a weird quirk of the test net.

Beyond that I think the thing that I'm most worried here is that what happens if the number is more than two decimal places. I wouldn't want the UI to jump in that case. Like, I'm wondering if we do something like:

  • If the estimated base fee is < 0.01, show < 0.01 GWEI.
  • If the estimated base fee is >= 0.01, show ${baseFee} GWEI where the base fee is rounded to 2 decimal places.

If you don't want to fix this now that's fine, we can do another pass, just throwing that out there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea, let me work on this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made the change.

@metamaskbot
Copy link
Collaborator

Builds ready [0ae68a9]
Page Load Metrics (734 ± 16 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint28477534613967
domContentLoaded6928357333316
load6938367343316
domInteractive6928347333316

highlights:

storybook

@metamaskbot
Copy link
Collaborator

Builds ready [505197b]
Page Load Metrics (840 ± 56 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30182249919694
domContentLoaded725109384011857
load725109384011856
domInteractive725109384011857

highlights:

storybook

@jpuri jpuri requested a review from mcmire November 18, 2021 13:24
mcmire
mcmire previously approved these changes Nov 18, 2021
Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Another minor thing, but this is good to go otherwise 👍🏻

<div className="network-status__info-field">
<span className="network-status__info-field-data">
{gasFeeEstimates?.estimatedBaseFee &&
`${gasFeeEstimates?.estimatedBaseFee} GWEI`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. That's odd.

Base automatically changed from EIP1559_V2_12451 to develop November 18, 2021 19:08
@metamaskbot
Copy link
Collaborator

@metamaskbot
Copy link
Collaborator

@jpuri
Copy link
Contributor Author

jpuri commented Nov 19, 2021

@mcmire , @darkwing , @NiranjanaBinoy : PR is updated and ready for re-review.

darkwing
darkwing previously approved these changes Nov 19, 2021
Copy link
Contributor

@darkwing darkwing left a comment

Choose a reason for hiding this comment

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

LGTM! One small suggestion would be to assign some of the numeric values as variables so we always know what they represent, but not a blocker.

@jpuri
Copy link
Contributor Author

jpuri commented Nov 22, 2021

LGTM! One small suggestion would be to assign some of the numeric values as variables so we always know what they represent, but not a blocker.

Done 👍 , I hope we soon move to typescript to fix these issues. Thx for the feedback

@metamaskbot
Copy link
Collaborator

@metamaskbot
Copy link
Collaborator

Copy link
Contributor

@mcmire mcmire left a comment

Choose a reason for hiding this comment

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

Sorry, two more comments and I swear I'm done 😂

<div className="network-status__info">
<div className="network-status__info__field">
<span className="network-status__info__field-data">
{estBaseFee >= 0.01 && `${estBaseFee} GWEI`}
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like based on the code above that the only reason that estBaseFee could be less than 0.01 is if gasFeeEstimates is null-ish or gasFeeEstimates.estimateBaseFee is null-ish. Assuming that is the case, that fact isn't entirely obvious based on this line alone. What if estBaseFee defaulted to null and then you said estBaseFee !== null && ${estBaseFee} GWEI` here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That default was actually inspired from this feedback: #12704 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made change again

if (gasFeeEstimates?.estimatedBaseFee) {
// estimatedBaseFee is not likely to be below 1, value .01 is used as test networks sometimes
// show have small values for it and more decimal places may cause UI to look broken.
estBaseFee = parseFloat(gasFeeEstimates?.estimatedBaseFee);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we have to be careful here, because ether can't be represented properly using floats (for instance, 15 WEI is 15 * 10**18, which gets corrupted into 1.5000000000000002e-16). I think the best thing here might be to run this through BigNumber. I feel like you might have run across this code already but I think you can do that by using toBigNumber.dec() from shared/modules/conversion.utils (unless there's another way you know to do this). Of course if this is already a BigNumber then you're good to go! But once you have a BigNumber you can call toFixed(2) on that to format it (while keeping it as a BigNumber).

@jpuri jpuri requested a review from mcmire November 22, 2021 18:32
darkwing
darkwing previously approved these changes Nov 22, 2021
@jpuri jpuri requested a review from darkwing November 22, 2021 19:10
@metamaskbot
Copy link
Collaborator

@jpuri jpuri merged commit fbc6f4e into develop Nov 23, 2021
@jpuri jpuri deleted the EIP1559_V2_12452 branch November 23, 2021 16:52
@github-actions github-actions bot locked and limited conversation to collaborators Nov 23, 2021
color={COLORS.UI4}
fontSize="12px"
>
<I18nValue
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a blocker, just curious, what was the impetus for creating this component over using the useI18nContext hook?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EIP-1559 V2: Edit gas fee modal - show network status details
5 participants