Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

1334/do not refetch when token added #1536

Conversation

alfetopito
Copy link
Contributor

Summary

Waterfalls into #1504

Addressing comment on #1395

No longer re-fetching orders when a token is added to the local list

To Test

  1. Trade with a token not part of the token list. Eg.: ZRX or BAT on rinkeby
  2. Open the console and filter by ApiOrdersUpdater
  3. Remove the custom added token
  • There should not be any new log entry like
    screenshot_2021-10-07_15-54-59
  1. Refresh the page
  • There should be only 1 log entry like the above after the refresh
  • The removed token should be back at the list of user tokens

@alfetopito alfetopito self-assigned this Oct 7, 2021
@alfetopito alfetopito requested a review from a team October 7, 2021 22:57
@alfetopito alfetopito requested review from a team and removed request for a team October 7, 2021 23:01
@github-actions
Copy link
Contributor

github-actions bot commented Oct 7, 2021

  • 🔭 GP Swap: Gnosis Protocol v2 Swap UI

@bh2smith
Copy link
Contributor

bh2smith commented Oct 8, 2021

For some reason I was notified about this PR. Is there something particular I was meant to be involved with here?

Copy link
Contributor

@bh2smith bh2smith left a comment

Choose a reason for hiding this comment

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

Looks pretty good. I really like the removed white space!

Copy link
Contributor

@W3stside W3stside left a comment

Choose a reason for hiding this comment

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

LGTM, nice work

@elena-zh
Copy link

elena-zh commented Oct 8, 2021

Works as described!
Few questions: why do I always get these errors?
image

I see these error in the log when I clear out custom tokens for Rinkeby, then switch to the Mainnet. Is this OK?
image

@alfetopito
Copy link
Contributor Author

For some reason I was notified about this PR. Is there something particular I was meant to be involved with here?

I picked the wrong team by accident (gp-contracts instead of gp-frontend)

@alfetopito
Copy link
Contributor Author

alfetopito commented Oct 8, 2021

Works as described! Few questions: why do I always get these errors? image

Also my fault, but from another issue #1534

I'll address that in another PR

@alfetopito
Copy link
Contributor Author

@elena-zh the fix for that msg is on #1546.
You can ignore that for now in this PR

Copy link
Contributor

@anxolin anxolin left a comment

Choose a reason for hiding this comment

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

The link to my comment doesn't work anymore, they were lost with all my other comments 😭

Anyways, I remember it, and the PR looks great! good job

@alfetopito alfetopito merged commit 7383984 into 1334/load-new-tokens-not-yet-loaded Oct 12, 2021
@alfetopito alfetopito deleted the 1334/do-not-refetch-when-token-added branch October 12, 2021 22:37
alfetopito added a commit that referenced this pull request Oct 15, 2021
* Added non-hook methods for dealing with contracts

* New hook useTokensLazy

* Exporting stuff from original codebase

* Added getMultipleCallsResults under custom/state/multicall/utils

Non-hook way of fetching multiple onchain queries through multicall

* Refactor ApiOrdersUpdater to load tokens not yet in the UI

* Typo fix

* 1334/do not refetch when token added (#1536)

* Removing annoying log

* No longer re-fetching orders when a token is added to the list

Co-authored-by: Leandro Boscariol <[email protected]>

* Refactored useTokensLazy:

- Added contracts cache
- Improved comments

* Improved doc string on multicall utils

Co-authored-by: Leandro Boscariol <[email protected]>
alfetopito added a commit that referenced this pull request Oct 15, 2021
* Added non-hook methods for dealing with contracts

* New hook useTokensLazy

* Exporting stuff from original codebase

* Added getMultipleCallsResults under custom/state/multicall/utils

Non-hook way of fetching multiple onchain queries through multicall

* Refactor ApiOrdersUpdater to load tokens not yet in the UI

* Typo fix

* 1334/do not refetch when token added (#1536)

* Removing annoying log

* No longer re-fetching orders when a token is added to the list

Co-authored-by: Leandro Boscariol <[email protected]>

* Refactored useTokensLazy:

- Added contracts cache
- Improved comments

* Improved doc string on multicall utils

Co-authored-by: Leandro Boscariol <[email protected]>
alfetopito added a commit that referenced this pull request Oct 21, 2021
* Added non-hook methods for dealing with contracts

* New hook useTokensLazy

* Exporting stuff from original codebase

* Added getMultipleCallsResults under custom/state/multicall/utils

Non-hook way of fetching multiple onchain queries through multicall

* Refactor ApiOrdersUpdater to load tokens not yet in the UI

* Typo fix

* 1334/do not refetch when token added (#1536)

* Removing annoying log

* No longer re-fetching orders when a token is added to the list

Co-authored-by: Leandro Boscariol <[email protected]>

* Refactored useTokensLazy:

- Added contracts cache
- Improved comments

* Improved doc string on multicall utils

Co-authored-by: Leandro Boscariol <[email protected]>
alfetopito added a commit that referenced this pull request Nov 29, 2021
* Added /account/<address>/orders api endpoint

* Added helper function to get explorer address link

* Requiring needed properties instead of concrete types on utils fns

* Added addOrUpdateOrdersBatch to orders/actions

* Added useAddOrUpdateOrdersBatch to orders/hooks

* Added addOrUpdateOrdersBatch to orders/reducer

* Added APIOrdersUpdater that checks for orders from API on connection

* Adjusted displayed orders:

- At most 10 regular orders and as much pending as there are
- Show only connected account orders
- Sort orders by creation date descending

* Show only txs for connected account

* Refactoring

* Don't actually need a helper fn...

* Added comment to make sort more explicit

* Using 'Link to Explorer' instead of 'Clear activities'

* Refactoring

* Refactor: cache tokens loaded const

* Refactor: removed duplicated css property

* Refactor: removed duplicated CSS property

* Refactor: extracted function transformApiOrderToStoreOrder

* Refactor: renamed _orders to apiOrders

* Refactor: removed duplicated CSS property

* Adjusting `View all orders` link size

* Added `View all orders` to the bottom of account activity

* Refactored computeOrderSummary to deal with pending orders

* Computing order summary for orders loaded from API

* Setting isCancelling state if order is pending and cancelled on API

* Actually syncing `isCancelling` flag for existing orders

* Refactor: created const for magic number MAXIMUM_ORDERS_TO_DISPLAY

* Refactor: simplified addOrUpdateOrdersBatch reducer

* Refactor: renamed API -> Api on file name

* Refactor: replaced magic number with AMOUNT_OF_ORDERS_TO_FETCH

* Refactor: converted classifyLocalStatus fn to a map

* Refactor: removed `Batch` from addOrUpdateOrders

* Refactor: moved error exit condition up

* 1334/load new tokens not yet loaded (#1504)

* Added non-hook methods for dealing with contracts

* New hook useTokensLazy

* Exporting stuff from original codebase

* Added getMultipleCallsResults under custom/state/multicall/utils

Non-hook way of fetching multiple onchain queries through multicall

* Refactor ApiOrdersUpdater to load tokens not yet in the UI

* Typo fix

* 1334/do not refetch when token added (#1536)

* Removing annoying log

* No longer re-fetching orders when a token is added to the list

Co-authored-by: Leandro Boscariol <[email protected]>

* Refactored useTokensLazy:

- Added contracts cache
- Improved comments

* Improved doc string on multicall utils

Co-authored-by: Leandro Boscariol <[email protected]>

* Fix new Erc20 import path

* Adjust to new multicall interface and fetchChunk changes

* Adapt to renamed of ApiOrderStatus to OrderTransitionStatus

* Adjusting (again) styles for `view all activity`

* Handling presignaturePending state from backend

* The order is concrete at this point, no need for `?.`

* 1334/only update connected wallet (#1684)

* Only update cancelled orders for connected wallet

* Only check for unfillable orders for connected wallet

* Only check pending orders for connected wallet

* Always create a new state object when adding an order (#1686)

Co-authored-by: Leandro Boscariol <[email protected]>

* Refactor: comparing account with order.owner lowercased for safety

Co-authored-by: Leandro Boscariol <[email protected]>

* Added new hook useTokenLazyNoMulticall to fetch token data one by one

* Using new hook to fetch tokens instead of multicall

* Removed multicall/utils

* Removed useTokensLazy hook

* Renamed file useTokensLazy to useTokenLazy

* Renamed useTokenLazyNoMulticall to useTokenLazy

* Removed unused import

* Updated debug log messages

* Small refactor in #1639 (#1857)

* Only init bytes32Contract if we really need to

* Fixing build error: only proceed if library is set

Co-authored-by: Leandro Boscariol <[email protected]>

* 1334/with swr (#1906)

* Refactor: removed unnecessary variable

* Added SWR as dev dependency

* Added hook useApiOrders using useSWR hook

* Using new hook for fetching api orders

* Removed unused imports...

Co-authored-by: Leandro Boscariol <[email protected]>

Co-authored-by: Leandro Boscariol <[email protected]>
Co-authored-by: Anxo Rodriguez <[email protected]>
anxolin pushed a commit to anxolin/cowswap that referenced this pull request Apr 1, 2022
* Added non-hook methods for dealing with contracts

* New hook useTokensLazy

* Exporting stuff from original codebase

* Added getMultipleCallsResults under custom/state/multicall/utils

Non-hook way of fetching multiple onchain queries through multicall

* Refactor ApiOrdersUpdater to load tokens not yet in the UI

* Typo fix

* 1334/do not refetch when token added (gnosis/cowswap#1536)

* Removing annoying log

* No longer re-fetching orders when a token is added to the list

Co-authored-by: Leandro Boscariol <[email protected]>

* Refactored useTokensLazy:

- Added contracts cache
- Improved comments

* Improved doc string on multicall utils

Co-authored-by: Leandro Boscariol <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants