-
Notifications
You must be signed in to change notification settings - Fork 32
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/masquerade checksum #1455
Fix/masquerade checksum #1455
Conversation
WalkthroughThe changes primarily focus on improving the address validation process in the application. The Changes
TipsChat with CodeRabbit Bot (
|
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1455 +/- ##
=============================================
Coverage 50.69210% 50.69210%
=============================================
Files 356 356
Lines 24274 24274
Branches 267 267
=============================================
Hits 12305 12305
Misses 10775 10775
Partials 1194 1194
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
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.
Review Status
Actionable comments generated: 1
Files selected for processing (3)
- packages/synapse-interface/components/Portfolio/SearchBar.tsx (2 hunks)
- packages/synapse-interface/slices/transactions/updater.tsx (2 hunks)
- packages/synapse-interface/utils/isValidAddress.tsx (1 hunks)
Additional comments (Suppressed): 7
packages/synapse-interface/slices/transactions/updater.tsx (1)
- 42-42: The
getValidAddress
function is imported from theisValidAddress
module. This function is used to validate and checksum addresses before querying.packages/synapse-interface/components/Portfolio/SearchBar.tsx (4)
16-16: The
getValidAddress
function is imported but not used in the old hunk. Ensure that all calls to this function throughout the codebase have been updated to match the new usage.71-73: The
getValidAddress
function is used to validate the search input. This is a good practice as it ensures that the address is valid before it is used in subsequent operations.78-83: The
fetchAndStoreSearchInputPortfolioBalances
function now uses the validated addresscheckSearchInputIsAddress
instead of the raw search input. This is a good practice as it ensures that the address is valid before it is used in the API call.86-88: The
clearSearchInput
function is now called whenmasqueradeActive
is true andcheckSearchInputIsAddress
is not null. This is a good practice as it ensures that the search input is cleared when it is not a valid address.packages/synapse-interface/utils/isValidAddress.tsx (2)
- 1-10: The
isValidAddress
function has been updated to catch and log bothInvalidAddressError
and any other exceptions. This is a good practice as it helps in debugging and understanding the nature of the error. However, thevalidatedAddress
variable is not used after being assigned. If it's not needed, consider removing it to clean up the code.try { const validatedAddress: string = getAddress(address) getAddress(address) return true } catch (e: InvalidAddressError | any) { console.error('isValidAddress error: ', e) return false }
- 13-21: The
getValidAddress
function is introduced. It is similar toisValidAddress
but returns the validated address instead of a boolean. This function can be useful when the validated address is needed for further processing. However, the function returnsnull
when an exception is caught. This could potentially lead to null pointer exceptions in the calling code. Consider throwing the exception to the caller to handle it appropriately.export const getValidAddress = (address: string): Address | any => { try { const validatedAddress: Address = getAddress(address) return validatedAddress } catch (e: InvalidAddressError | any) { console.error('getValidAddress error: ', e) return null throw e } }
searchedBalancesAndAllowances | ||
)[0] as Address | ||
fetchUserHistoricalActivity({ | ||
address: queriedAddress, | ||
address: getValidAddress(queriedAddress), | ||
startTime: queryHistoricalTime, | ||
}) | ||
fetchUserPendingActivity({ | ||
address: queriedAddress, | ||
address: getValidAddress(queriedAddress), | ||
startTime: queryPendingTime, | ||
}) |
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.
The getValidAddress
function is used to validate the queriedAddress
before it is used in the fetchUserHistoricalActivity
and fetchUserPendingActivity
functions. This ensures that the address is valid and checksummed before querying, improving the reliability of the system.
- fetchUserHistoricalActivity({
- address: queriedAddress,
- startTime: queryHistoricalTime,
- })
- fetchUserPendingActivity({
- address: queriedAddress,
- startTime: queryPendingTime,
- })
+ fetchUserHistoricalActivity({
+ address: getValidAddress(queriedAddress),
+ startTime: queryHistoricalTime,
+ })
+ fetchUserPendingActivity({
+ address: getValidAddress(queriedAddress),
+ startTime: queryPendingTime,
+ })
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.
Review Status
Actionable comments generated: 0
Files selected for processing (2)
- packages/synapse-interface/components/Portfolio/SearchBar.tsx (2 hunks)
- packages/synapse-interface/slices/transactions/updater.tsx (2 hunks)
Additional comments (Suppressed): 5
packages/synapse-interface/components/Portfolio/SearchBar.tsx (3)
16-16: The
getValidAddress
function is imported from theisValidAddress
module. This function is used to validate and checksum the address before querying.71-73: The
searchInputIsAddress
variable is replaced withchecksumValidAddress
. This new variable stores the validated and checksummed address fromgetValidAddress
.76-89: The
fetchAndStoreSearchInputPortfolioBalances
function now useschecksumValidAddress
instead ofsearchInput
. This ensures that the address is validated and checksummed before querying. The dependencies of theuseEffect
hook are updated accordingly.packages/synapse-interface/slices/transactions/updater.tsx (2)
42-42: The
getValidAddress
function is imported from theisValidAddress
module. This function is used to validate and checksum the address before querying. This is a good practice as it ensures the reliability of the system in Masquerade Mode.98-108: The
getValidAddress
function is used to validate the queried address before making API calls infetchUserHistoricalActivity
andfetchUserPendingActivity
functions. This is a good practice as it ensures that the address is valid and checksummed before querying, reducing the chances of errors and improving the reliability of the system.- fetchUserHistoricalActivity({ - address: queriedAddress, - startTime: queryHistoricalTime, - }) - fetchUserPendingActivity({ - address: queriedAddress, - startTime: queryPendingTime, - }) + fetchUserHistoricalActivity({ + address: getValidAddress(queriedAddress), + startTime: queryHistoricalTime, + }) + fetchUserPendingActivity({ + address: getValidAddress(queriedAddress), + startTime: queryPendingTime, + })
Pairing with @abtestingalpha to create fix for double checking queryable address is checksum'd prior to querying when in Masquerade Mode.
090131e56c58d4c5d6ca1caf15524e8fc5f45856: synapse-interface preview link
Summary by CodeRabbit
eb5b76602bbb85561de83722483acd26883f3325: synapse-interface preview link