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

[2] refactor(tokens): clean up token consts and use TokenWithLogo #3190

Merged
merged 6 commits into from
Oct 26, 2023

Conversation

shoom3301
Copy link
Collaborator

@shoom3301 shoom3301 commented Oct 10, 2023

Summary

One of our strategic goals is independence from Uniswap legacy.
Currently, we widely use Currency, NativeCurrency, Token, and CurrencyAmount from @uniswap/sdk-core.
In the previous PR, I added a new entity TokenWithLogo. It should replace Currency, NativeCurrency, Token from Uniswap.
Currently the migration in the intermediate state, we have to work on it more in the future.

What is changed:

  • GpEther and GnosisChainNativeCurrency are replaced by NATIVE_CURRENCY_BUY_TOKEN
  • currency.isNative / currency.isToken is replaced by getIsNativeToken()
  • currency.wrapped is replaced by getWrappedToken()
  • libs/common-const/src/tokens.ts was split into several files

Please, use the new helpers in your next changes.

To Test

Please, test everything in #3201

@vercel
Copy link

vercel bot commented Oct 10, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
swap-dev 🔄 Building (Inspect) Visit Preview Oct 26, 2023 0:39am

🌃 Cosmos ↗︎

Copy link
Collaborator

@alfetopito alfetopito left a comment

Choose a reason for hiding this comment

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

More nitpicks

libs/common-const/src/nativeAndWrappedTokens.ts Outdated Show resolved Hide resolved
libs/common-utils/src/tokens.ts Show resolved Hide resolved
@@ -2,7 +2,7 @@
// + logic for chainId switch to/from xDAI
import { SupportedChainId } from '@cowprotocol/cow-sdk'

import { XDAI_SYMBOL } from './constants'
import { XDAI_SYMBOL } from '../tokens'
Copy link
Contributor

Choose a reason for hiding this comment

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

I found strange that getChainCurrencySymbols is inside a folder called gnosis_chain but accepts any chain as a parameter

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Indeed! Considering the comment in the file beginning it must be an artifact from Uniswap era.
To avoid the scope blowing I prefer to fix it in the another iteration

libs/common-const/src/cowprotocolTokenLists.ts Outdated Show resolved Hide resolved
return null
}

return currency?.address || (currency as { tokenInfo?: { address?: string } })?.tokenInfo?.address || null
return currency.address
Copy link
Contributor

Choose a reason for hiding this comment

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

heheh, looks simpler

typeof params !== 'number' && 'chainId' in params && 'symbol' in params

/**
* TODO: Eventually, we should get rid of uniswap entities and use our own
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

…cowswap into refactor/tokens-consts

# Conflicts:
#	libs/common-const/src/tokens.ts
#	libs/common-utils/src/index.ts
* refactor(tokens): remove excessive types and consts (#3196)

* refactor(tokens): integrate TokenLogo component (#3197)

* refactor(tokens): wire up components to new hooks (#3198)

* refactor(tokens): remove Uniswap currency entities usage (#3199)

* refactor(tokens): use new tokens UI and logic by default (#3200)

* fix(tokens): fix e2e tests for tokens updates (#3193)

* refactor(tokens): remove legacy code (#3194)

* fix(tokens): fix tokens list loading state (#3201)
@shoom3301 shoom3301 merged commit f0f9997 into refactor/tokens-lib Oct 26, 2023
4 of 5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 26, 2023
@alfetopito alfetopito deleted the refactor/tokens-consts branch October 26, 2023 17:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants