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 send max issue #22694

Merged
merged 5 commits into from
Feb 7, 2024
Merged

Fix send max issue #22694

merged 5 commits into from
Feb 7, 2024

Conversation

OGPoyraz
Copy link
Member

@OGPoyraz OGPoyraz commented Jan 29, 2024

Description

Currently "send max" eth experience is broken. It doesn't recalculate the send amount due to gas changes while confirming transaction.

Related issues

Fixes:

Manual testing steps

See before/after recordings

Screenshots/Recordings

Before

not.updating.mov

After

working.mov

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.

@OGPoyraz OGPoyraz added the team-confirmations-system DEPRECATED: please use "team-confirmations" label instead label Jan 29, 2024
@metamaskbot
Copy link
Collaborator

Builds ready [433c3a9]
Page Load Metrics (727 ± 18 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint90157105147
domContentLoaded9441673
load6748137273818
domInteractive9441673
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 3.62 KiB (0.05%)
  • common: 0 Bytes (0.00%)

@OGPoyraz OGPoyraz marked this pull request as ready for review January 31, 2024 08:36
@OGPoyraz OGPoyraz requested a review from a team as a code owner January 31, 2024 08:36
Copy link

codecov bot commented Jan 31, 2024

Codecov Report

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

Comparison is base (ff0a27d) 68.34% compared to head (bd0e5ef) 68.34%.
Report is 8 commits behind head on develop.

Files Patch % Lines
...saction-base/confirm-transaction-base.component.js 28.57% 5 Missing ⚠️
ui/ducks/send/send.js 80.00% 1 Missing ⚠️
...saction-base/confirm-transaction-base.container.js 85.71% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #22694   +/-   ##
========================================
  Coverage    68.34%   68.34%           
========================================
  Files         1088     1088           
  Lines        42813    42834   +21     
  Branches     11396    11405    +9     
========================================
+ Hits         29258    29273   +15     
- Misses       13555    13561    +6     

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

@sleepytanya
Copy link
Contributor

The maximum send amount is accurately adjusted in response to fluctuations in gas fees.
Chrome 121.0.6167.139

chrome.mov

Firefox 122.0

firefox.mov

ui/ducks/confirm-transaction/confirm-transaction.duck.js Outdated Show resolved Hide resolved
ui/ducks/confirm-transaction/confirm-transaction.duck.js Outdated Show resolved Hide resolved
ui/ducks/confirm-transaction/confirm-transaction.duck.js Outdated Show resolved Hide resolved
const gasEstimationObject = getGasEstimationObject(
state,
{ gasFeeEstimates, gasEstimateType },
state.confirmTransaction.txData,
Copy link
Contributor

@dbrans dbrans Feb 1, 2024

Choose a reason for hiding this comment

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

state.confirmTransaction.txData is repeated to compute txId and also below to compute transactionMeta. It might be more readable to store it in an intermediate variable at the top of the function.

const txData = state.confirmTransaction?.txData

state,
{ gasFeeEstimates, gasEstimateType },
) => {
const txId = state.confirmTransaction?.txData?.id;
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder about all the digging deep into state in this function: are there existing selectors to get this data? Should there be?

ui/ducks/send/send.js Outdated Show resolved Hide resolved
ui/ducks/send/send.js Outdated Show resolved Hide resolved
ui/ducks/send/send.js Outdated Show resolved Hide resolved
ui/ducks/send/send.js Outdated Show resolved Hide resolved
ui/store/actions.ts Outdated Show resolved Hide resolved
@metamaskbot
Copy link
Collaborator

Builds ready [db38892]
Page Load Metrics (743 ± 17 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint85138105115
domContentLoaded9201442
load6918057433417
domInteractive9201442
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.19 KiB (0.02%)
  • common: 0 Bytes (0.00%)

addTransactionAndRouteToConfirmationPage(txParams, {
sendFlowHistory: draftTransaction.history,
type: transactionType,
}),
);

dispatch(
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed we're not using await with dispatch here, but we do throughout the code above. Looking at the return type of signTransaction, dispatch isn't even async. Could this be a good chance to make things more consistent and less confusing in this code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, added await to dispatch(setMaxValueMode(/* ... */)))

Copy link
Member

Choose a reason for hiding this comment

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

Is this not just a side effect of the action you are dispatching?

Some actions will simply update state entirely synchronously and so don't need an await where as many will submit a request to the background and therefore return a promise that can be awaited if needed.

Copy link
Member Author

@OGPoyraz OGPoyraz Feb 7, 2024

Choose a reason for hiding this comment

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

Maybe I misunderstood Derek here and for sure await will not have any effect at all since it is synchronous call.

@metamaskbot
Copy link
Collaborator

Builds ready [bd0e5ef]
Page Load Metrics (809 ± 22 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint98136115115
domContentLoaded10471884
load7469088094522
domInteractive10471894
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: 1.16 KiB (0.02%)
  • common: 0 Bytes (0.00%)

@OGPoyraz OGPoyraz merged commit 6207da3 into develop Feb 7, 2024
68 checks passed
@OGPoyraz OGPoyraz deleted the send-max-eth-issue branch February 7, 2024 09:03
@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2024
@metamaskbot metamaskbot added the release-11.11.0 Issue or pull request that will be included in release 11.11.0 label Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
QA Passed release-11.11.0 Issue or pull request that will be included in release 11.11.0 team-confirmations-system DEPRECATED: please use "team-confirmations" label instead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants