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: confirmation when transaction (STX) is pending cross-network #25629

Merged
merged 6 commits into from
Jul 4, 2024

Conversation

vinistevam
Copy link
Contributor

@vinistevam vinistevam commented Jul 2, 2024

Description

This PR aims to fix the issue when a user has a Smart transaction in a pending state and initiates a new transaction through a dApp on a different network, the dApp transaction is generated with an empty nonce.

The issue happens due to a limitation on nonce management in the Transaction Controller. The nonce locks for the first transaction (STX) and only allows the user to submit another transaction once the first one is confirmed. This is the current behaviour for STX with transactions in the same network. This update extends the validation across different networks.

Open in GitHub Codespaces

Related issues

Fixes: #25579

Manual testing steps

  1. Turn on nonce customization in the SEttings->Advanced
  2. Connect to Ethereum
  3. Send STX (set low gas fee so the STX stays in 'Pending' state for awhile)
  4. Connect to dapp (Pancake Swap, Uniswap) to BNB or other network
  5. Start a dapp transaction
  6. Notice that nonce field is empty
  7. Confirm the transaction, see the loading spinner

Screenshots/Recordings

Screencast.from.02-07-2024.14.05.18.webm

Before

After

Pre-merge author checklist

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 vinistevam added the team-confirmations Push issues to confirmations team label Jul 2, 2024
Copy link
Contributor

github-actions bot commented Jul 2, 2024

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.

@vinistevam vinistevam marked this pull request as ready for review July 2, 2024 13:48
@vinistevam vinistevam requested review from a team as code owners July 2, 2024 13:48
Copy link

codecov bot commented Jul 2, 2024

Codecov Report

Attention: Patch coverage is 64.00000% with 9 lines in your changes missing coverage. Please review.

Project coverage is 69.68%. Comparing base (e0db3ef) to head (fe62ee6).
Report is 1 commits behind head on develop.

Files Patch % Lines
...saction-base/confirm-transaction-base.component.js 18.18% 9 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##           develop   #25629   +/-   ##
========================================
  Coverage    69.67%   69.68%           
========================================
  Files         1366     1366           
  Lines        48231    48237    +6     
  Branches     13304    13306    +2     
========================================
+ Hits         33604    33610    +6     
  Misses       14627    14627           

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

@metamaskbot
Copy link
Collaborator

Builds ready [784cd3d]
Page Load Metrics (166 ± 166 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint751491132110
domContentLoaded116936178
load501669166346166
domInteractive116936178
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 66 Bytes (0.00%)
  • common: 179 Bytes (0.00%)

@vinistevam vinistevam marked this pull request as draft July 2, 2024 15:05
@vinistevam vinistevam marked this pull request as ready for review July 2, 2024 15:58
@metamaskbot
Copy link
Collaborator

Builds ready [9672ed5]
Page Load Metrics (285 ± 266 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint722991314723
domContentLoaded992392411
load492165285553266
domInteractive992392411
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 28 Bytes (0.00%)
  • common: 179 Bytes (0.00%)

@sleepytanya
Copy link
Contributor

User cannot send another transaction while having STX in Pending state. Previous transaction is still being signed or submitted message is shown and Confirm button is disabled.

123.mov

@sleepytanya
Copy link
Contributor

sleepytanya commented Jul 2, 2024

@vinistevam @bschorchit

Should all types of txs be disabled if user has Pending STX?

Confusing UX when tx are of Approval type.

  1. Send Approval (any tx should work I think) STX on mainnet
  2. Start Approval transaction on another network
  3. MM popup shows Submitting your transaction STX modal (user can't see the second transaction - which is expected) but it this case user also can't see Previous tx is still being signed or submitted message
  4. Close the popup
  5. When Approval STX is confirmed the popup is not visible (stays behind the browser window - this is another bug), user have to look for the popup / click on the blue badge again / reject, confirm from the Activity tab.
approval.mov

The error in the console when the STX gets confirmed:

Screenshot 2024-07-02 at 15 24 04

matthewwalsh0
matthewwalsh0 previously approved these changes Jul 3, 2024
},
(transactions) => transactions,
);

export const getCurrentNetworkTransactions = createDeepEqualSelector(
Copy link
Member

Choose a reason for hiding this comment

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

Should we change this to use getTransactions as a dependency to avoid the duplicated sorting?

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 tried that yesterday but some of the unit tests started to fail. After your comment, I tried again, found the issue in the unit tests, and pushed this change to use getTransactions.

Copy link

sonarcloud bot commented Jul 3, 2024

@metamaskbot
Copy link
Collaborator

Builds ready [fe62ee6]
Page Load Metrics (406 ± 326 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint572701104321
domContentLoaded97428178
load402149406680326
domInteractive97428168
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 28 Bytes (0.00%)
  • common: 117 Bytes (0.00%)

@vinistevam vinistevam merged commit a935093 into develop Jul 4, 2024
73 checks passed
@vinistevam vinistevam deleted the fix-stx-pending-different-network branch July 4, 2024 20:01
@github-actions github-actions bot locked and limited conversation to collaborators Jul 4, 2024
@metamaskbot metamaskbot added the release-12.2.0 Issue or pull request that will be included in release 12.2.0 label Jul 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.2.0 Issue or pull request that will be included in release 12.2.0 team-confirmations Push issues to confirmations team
Projects
None yet
5 participants