Skip to content
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

swap seach popular in rainbow #1696

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

greg-schrammel
Copy link
Contributor

@greg-schrammel greg-schrammel commented Sep 9, 2024

Fixes BX-####
Figma link (if any):

What changed (plus any additional context for devs)

Screen recordings / screenshots

Screen.Recording.2024-09-09.at.17.23.01.mov

What to test

Copy link

linear bot commented Sep 9, 2024

Comment on lines 109 to 120
isNativeAsset: [
`${ETH_ADDRESS}_${ChainId.mainnet}`,
`${ETH_ADDRESS}_${ChainId.optimism}`,
`${ETH_ADDRESS}_${ChainId.arbitrum}`,
`${BNB_BSC_ADDRESS}_${ChainId.bsc}`,
`${MATIC_POLYGON_ADDRESS}_${ChainId.polygon}`,
`${ETH_ADDRESS}_${ChainId.base}`,
`${ETH_ADDRESS}_${ChainId.zora}`,
`${ETH_ADDRESS}_${ChainId.avalanche}`,
`${ETH_ADDRESS}_${ChainId.blast}`,
`${ETH_ADDRESS}_${ChainId.degen}`,
].includes(`${a.uniqueId}_${chainId}`),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced this with isNativeAsset from ~/core/utils/chains, fixes some chains like degen that was not getting the right native

Comment on lines 515 to 518
if (popularAssets) {
sections.push({ id: 'popular', data: popularAssets });
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to limit to 3 results like in the app?

Copy link
Member

@estebanmino estebanmino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@@ -508,6 +512,10 @@ export function useSearchCurrencyLists({
return sections;
}

if (popularAssets) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think you need to make sure there is no overlap between assets in the popular section and assets in other sections. here's the app logic https://github.com/rainbow-me/rainbow/blob/develop/src/__swaps__/screens/Swap/hooks/useSearchCurrencyLists.ts

lmk if you want me to explain more

@greg-schrammel greg-schrammel marked this pull request as draft September 18, 2024 14:03
@greg-schrammel greg-schrammel marked this pull request as ready for review October 3, 2024 15:52
OP_ADDRESS,
POL_POLYGON_ADDRESS,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eslint sort imports rule

Comment on lines +71 to +84
/**
* @returns a new array of `assets` that don't overlap with `others`
*/
function difference(
assets: SearchAsset[],
others: (SearchAsset | undefined | null)[],
) {
const _others = others.filter(Boolean);
return assets.filter((asset) => {
return !_others.some((other) =>
isLowerCaseMatch(other.uniqueId, asset.uniqueId),
);
});
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

made a more generic function to filter the sections, took the name from new Set().difference()

this changes for example

filterAssetsFromBridgeAndAssetToSell(sectionAssets)

for

difference(sectionAssets, [bridgeAsset, assetToSell])

I think its more extensible and easier to understand the intention

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants