-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat: special case arb search #6584
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #6584 +/- ##
==========================================
- Coverage 62.62% 62.47% -0.15%
==========================================
Files 714 714
Lines 21039 21044 +5
Branches 6956 6956
==========================================
- Hits 13175 13147 -28
- Misses 7786 7819 +33
Partials 78 78
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.
src/graphql/data/SearchTokens.ts
Outdated
// Always priotize natives, and if both tokens are native, prefer native on current chain (i.e. Matic on Polygon over Matic on Mainnet ) | ||
if (current.standard === 'NATIVE' && (existing.standard !== 'NATIVE' || current.chain === searchChain)) return true | ||
// Special case: always prefer Arbitrum ARB over Mainnet ARB | ||
if (current.address === ARB.address) return current |
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.
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.
Returns expected result, however not sure if second check is necessary
if (current.address?.toLowerCase() === ARB_ADDRESS) return current | ||
if (existing.address?.toLowerCase() === ARB_ADDRESS) return existing |
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.
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.
It depends on the order the backend returns the two ARB tokens in, if the backend started returning them in the opposite order, only having one check wouldn't work.
@@ -87,7 +99,7 @@ export function useSearchTokens(searchQuery: string, chainId: number) { | |||
data?.searchTokens?.forEach((token) => { | |||
if (token.project?.id) { | |||
const existing = selectionMap[token.project.id] | |||
if (isMoreRevelantToken(token, existing, searchChain)) selectionMap[token.project.id] = token |
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.
it looks like there's a behavior change here that might not be intentional--in the old one there were cases where selectionMap[token.project.id]
wouldn't be assigned a value here, but now every iteration assigns a value. Is that intended?
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.
In cases where isMoreRevelantToken
would've returned false, dedupeCrosschainTokens
returns existing
, so this is just a refactor for readability
Description
Special cases the ARB token on Arbitrum to always display over the ARB token on Mainnet in search results when both are returned by the backend, regardless of the user's current chain.
Also cleans up / renames the cross token search code to make functionality more clear.
Linear ticket
Screen capture
QA (ie manual testing)