-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 missing conversion rates in swaps token drop down #12420
fix missing conversion rates in swaps token drop down #12420
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. |
068ee11
to
6b22e5a
Compare
Builds ready [c674179]
Page Load Metrics (421 ± 55 ms)
|
ui/hooks/useTokensToSearch.js
Outdated
@@ -172,6 +172,10 @@ export function useTokensToSearch({ | |||
return new BigNumber(rawFiat || 0).gt(secondRawFiat || 0) ? -1 : 1; | |||
}, | |||
); | |||
|
|||
// the defaultToken/asset should always be at the top of the owned section | |||
tokensToSearchBuckets.owned.unshift(memoizedDefaultToken); |
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.
Nice! My only concern was if owned was ever not an array, and ui/hooks/useTokensToSearch.js
shows it initialized as empty, so we're good!
c674179
to
6d1876b
Compare
…own with full renderable data regardless of whether swaps tokens are available
6d1876b
to
a5171c4
Compare
@@ -139,7 +142,7 @@ export function useTokensToSearch({ | |||
}; | |||
|
|||
const memoizedSwapsAndUserTokensWithoutDuplicities = uniqBy( | |||
[...memoizedTokensToSearch, ...memoizedUsersToken], | |||
[memoizedDefaultToken, ...memoizedTokensToSearch, ...memoizedUsersToken], |
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 found that this change was required to get the native asset to consistently show conversionRate as well. Otherwise we would use the swapsTokens
instance of ETH (when swapsTokens are available, which appears to be intermittent?) which has no balance information resulting in not showing conversions. cc @dan437 @danjm
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 think this change is fine
Builds ready [a5171c4]
Page Load Metrics (497 ± 59 ms)
|
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've tested the changes locally and I can see fiat prices now + tokens are sorted by their fiat value. Great job!
Builds ready [8272efd]
Page Load Metrics (453 ± 65 ms)
|
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.
My only nit is that we run toChecksumHexAddress(address)
twice, maybe we could store that value in a const
instead of doing the work twice, but not a huge deal.
@danjm this okay to merge and pull into 10.3.0? Does it resolve all concerns? |
Explanation: Conversion rates were missing in the swaps "from token" searchable dropdown because contractExchangeRates are keyed with addresses in checksum format. This is yet another case where address format normalization needs to take place globally
additionally the defaultToken (ETH) appeared to only render conversionRates when
swapsTokens
were unavailable so this PR alters logic for deriving the tokensToSearchBuckets such that we guarantee the defaultToken/native asset has data required to show fiat conversion available.