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

fix: erc20 import error

Open sahar-fehri opened this issue 9 months ago • 6 comments

Description

When you try to import an ERC20, it will require clicking on the next button twice before moving to the confirmation modal. You will also see this error in the console:

SES_UNHANDLED_REJECTION: Error: Invariant failed: A state mutation was detected between dispatches, in the path 'metamask.tokenList.0x0000000000300dd8b0230efcfef136ecdf6abcde.unlisted'. This may cause incorrect behavior. (https://redux.js.org/style-guide/style-guide#do-not-mutate-state) (see video)

I used spread operator to update the "unlisted" value in tokens instead of changing its value directly.

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Go to home age
  2. Click on import tokens and select any token from the list
  3. Click on "Next" button. Make sure you have only clicked the button once and you were moved successfully to confirmation page.
  4. The error should not appear in console.

Screenshots/Recordings

Before

https://github.com/MetaMask/metamask-extension/assets/10994169/d207512e-2523-464b-a7fd-198110d1e0fb

After

https://github.com/MetaMask/metamask-extension/assets/10994169/d00b829b-fc0a-4272-af52-573bd98f23a1

Pre-merge author checklist

  • [ ] I’ve followed MetaMask Coding Standards.
  • [ ] I've completed the PR template to the best of my ability
  • [ ] 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.

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.

sahar-fehri avatar May 20 '24 12:05 sahar-fehri

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 May 20 '24 12:05 github-actions[bot]

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 67.37%. Comparing base (d8fd077) to head (250d7a9).

:exclamation: Current head 250d7a9 differs from pull request most recent head c811dff

Please upload reports for the commit c811dff to get more accurate results.

Files Patch % Lines
ui/store/actions.ts 0.00% 2 Missing :warning:
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #24620      +/-   ##
===========================================
- Coverage    67.40%   67.37%   -0.02%     
===========================================
  Files         1289     1289              
  Lines        50248    50221      -27     
  Branches     13011    13005       -6     
===========================================
- Hits         33865    33835      -30     
- Misses       16383    16386       +3     

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

codecov[bot] avatar May 20 '24 12:05 codecov[bot]

Builds ready [250d7a9]
Page Load Metrics (294 ± 326 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint6811786136
domContentLoaded9301463
load542477294679326
domInteractive9301463
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 20 Bytes (0.00%)

metamaskbot avatar May 20 '24 13:05 metamaskbot

LGTM ! Smooth fix !

DDDDDanica avatar May 21 '24 12:05 DDDDDanica

Builds ready [c811dff]
Page Load Metrics (944 ± 519 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint57157952411
domContentLoaded94317115
load4725649441081519
domInteractive84317115
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 0 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 20 Bytes (0.00%)

metamaskbot avatar May 21 '24 15:05 metamaskbot