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

feat(swap): default 1 native to usdc on the swap page #3347

Merged
merged 9 commits into from
Feb 28, 2022

Conversation

moodysalem
Copy link
Contributor

No description provided.

@vercel
Copy link

vercel bot commented Feb 23, 2022

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

interface – ./

🔍 Inspect: https://vercel.com/uniswap/interface/3bhVHb6reATmGLVcyFHm7q8yDHHC
✅ Preview: https://interface-git-default-1-eth-to-usdc-uniswap.vercel.app

widgets – ./

🔍 Inspect: https://vercel.com/uniswap/widgets/B27DjD6H4vQHQP6cEb38Jb8mtd3c
✅ Preview: https://widgets-git-default-1-eth-to-usdc-uniswap.vercel.app

@moodysalem
Copy link
Contributor Author

integ tests are failing because the rinkeby usdc we're importing from smart-order-router is not on the default token list
image

could simply add it to the default token list

@moodysalem
Copy link
Contributor Author

alternately, we shouldn't show this warning if the token came from a shorthand

@moodysalem moodysalem changed the title feat(swap): default 1 eth to usdc on the swap page feat(swap): default 1 native to usdc on the swap page Feb 23, 2022
src/constants/tokens.ts Outdated Show resolved Hide resolved
src/lib/hooks/useCurrency.ts Outdated Show resolved Hide resolved
const address = isAddress(tokenAddress)
const token: Token | undefined = address ? tokens[address] : undefined

const tokenFromNetwork = useTokenFromNetwork(token ? undefined : address ? address : undefined)
Copy link
Contributor

Choose a reason for hiding this comment

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

can this be simplified as useTokenFromNetwork(token ?? address ? address : undefined)? Nested ternary is hard to read.

If you change address to be isAddress(tokenAddress) || undefined, you can just have it be token ?? 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.

i don't think that's the same. we want to not load from the network if the token is on the token data map. token ?? address ? address : undefined would evaluate to address if token was defined

Copy link
Contributor

Choose a reason for hiding this comment

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

token || (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.

also not equivalent, we want it to be undefined if token is defined

src/state/swap/hooks.tsx Outdated Show resolved Hide resolved
src/pages/Swap/index.tsx Show resolved Hide resolved
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.

None yet

2 participants