-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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: safeguard utill/address functions for undefined arguments #7056
Conversation
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. |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #7056 +/- ##
==========================================
+ Coverage 33.08% 33.15% +0.06%
==========================================
Files 1005 1005
Lines 32649 32654 +5
Branches 8395 8398 +3
==========================================
+ Hits 10803 10827 +24
+ Misses 21846 21827 -19
☔ View full report in Codecov by Sentry. |
The
Do you confirm @jpcloureiro ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Good catch. That function shouldn't return a boolean. I'll make the function throw an error if all calls happen to be wrapped inside a try / catch block |
getAddressAccountType throws an error when |
Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: not sure why you don't cascade the checks in the functions.
Right now, each address check function has to do similar checks (defined, length, valid hex, regex,...).
Why not just one that checks the definition, then the format?
In the end, all of the functions that use an address seems to require a fully valid hex ethereum address. So I feel that one "isValidEthAddress" that does a definition check and a regex match would be enough to be called from all other places.
It would also reduce the number of places where you do checks and make code stronger and easier to understand to me.
We should be using isValidAddress from @ethereumjs/util to validate the This validation should occur at a root level rather than in the multiple places where it is being used. With that in mind, I prefer to leave those changes outside this PR for the sake of keeping the scope close to the issue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Co-authored-by: LeoTM <1881059+leotm@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments - Do we know the root of why selectedAddress would be undefined?
Test recording as shared on Slack Sep 4 |
Bad redux hydration is one of them |
Is there a solution for fixing the root cause (fixing the bad rehydration condition)? Currently, the patch still results in the app showing potentially incorrect states since selectedAddress can still be undefined. |
Hey, I've updated the PR description to provide more context around this approach. The motivation for this PR relies on preventing a specific error that has been reported multiple times. All of them appear to occur on the transaction screen. The approach is to allow specific functions to not throw errors when their arguments are undefined rather than preventing the Efforts on preventing |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not see anything out of the ordinary to report here. ✅
Development & PR Process
release-xx
label to identify the PR slated for a upcoming release (will be used in release discussion)needs-dev-review
label when work is completedneeds-qa
: PR requires manual QA.No QA/E2E only
: PR does not require any manual QA effort. Prior to merging, ensure that you have successful end-to-end test runs in Bitrise.Spot check on release build
: PR does not require feature QA but needs non-automated verification. In the description section, provide test scenarios. Add screenshots, and or recordings of what was tested.QA Passed
label when QA has signed off (Only required if the PR was labeled withneeds-qa
)team-
(orexternal-contributor
label if your not a MetaMask employee)Description
This PR aims at preventing the appearance of the ErrorBoundary screen on a specific user flow that seems to be the most affected by this bug
The user flow we're touching is the navigation to the Transaction screen while the wallet has a non-empty list of transactions to be displayed.
is the error we've been seeing the most.
This fix only implements an access check on a couple of util functions inside
app/util/address
that are being used in the Transaction screen componentsIssue
fixes #6771
Checklist