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

[4.1] refactor(tokens): remove excessive types and consts #3196

Merged
merged 9 commits into from
Oct 26, 2023

Conversation

shoom3301
Copy link
Collaborator

@shoom3301 shoom3301 commented Oct 10, 2023

Summary

In this PR I removed some excessive types and consts from the legacy token lists module.

  1. Removed DEFAULT_NETWORK_FOR_LISTS by replacing it with SupportedChainId.MAINNET
  2. Removed OrderID (it's actually just string), and UnsupportedToken (not relevant anymore)
  3. Removed WithChainId

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:38am

🌃 Cosmos ↗︎

@shoom3301 shoom3301 changed the title Refactor/tokens lib wiring 1 [4.1] refactor(tokens): remove excessive types and consts Oct 10, 2023
@shoom3301 shoom3301 self-assigned this Oct 10, 2023
@shoom3301 shoom3301 requested a review from a team October 11, 2023 12:17
@shoom3301 shoom3301 marked this pull request as ready for review October 11, 2023 12:17
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.

Some concerns, nothing major, though

@@ -200,7 +200,7 @@ async function _updateOrders({

if (presigned.length > 0) {
// Only mark as presigned the orders we were not aware of their new state
const presignedOrderIds = presigned as OrderID[]
const presignedOrderIds = presigned as string[]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the casting still needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Yep

Copy link
Contributor

Choose a reason for hiding this comment

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

but I guess is because it can be one of these two types: OrderFulfillmentData | string

Why do we assume is a string? or maybe the question is, why did we do such a strange type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, I don't know, it also looks weird to me

apps/cowswap-frontend/src/common/updaters/orders/utils.ts Outdated Show resolved Hide resolved
@@ -119,7 +119,7 @@ class GasFeeApi {
return response.json()
}

async getGasPrices(chainId: ChainId = DEFAULT_NETWORK_FOR_LISTS): Promise<GasFeeEndpointResponse> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe is not bad to have a default network (imagine a widget in Gnosis Chain only app)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We still have it.
DEFAULT_NETWORK_FOR_LISTS === ChainId.MAINNET

@@ -200,7 +200,7 @@ async function _updateOrders({

if (presigned.length > 0) {
// Only mark as presigned the orders we were not aware of their new state
const presignedOrderIds = presigned as OrderID[]
const presignedOrderIds = presigned as string[]
Copy link
Contributor

Choose a reason for hiding this comment

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

but I guess is because it can be one of these two types: OrderFulfillmentData | string

Why do we assume is a string? or maybe the question is, why did we do such a strange type?

@@ -199,7 +199,7 @@ function getEthFlowOverridesOnSelect(
): Pick<SwapState, 'independentField' | 'typedValue'> {
if (
inputCurrencyId?.toUpperCase() ===
NATIVE_CURRENCY_BUY_TOKEN[state.chainId || ChainId.MAINNET]?.symbol?.toUpperCase()
NATIVE_CURRENCY_BUY_TOKEN[(state.chainId as ChainId) || ChainId.MAINNET]?.symbol?.toUpperCase()
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't state.chainId be of type ChainId in the first place? or this is a number to allow users to be in any other network?
and if so, is the casting safe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It definitely must. I'm afraid of changing SwapState, it will cause of lots of new changes

…ocol/cowswap into refactor/tokens-lib-wiring-1

# Conflicts:
#	apps/cowswap-frontend/src/api/gnosisProtocol/index.ts
* 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 eefe35e into refactor/token-search-ui 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-lib-wiring-1 branch October 26, 2023 17:14
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