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

1334/only update connected wallet #1684

Conversation

alfetopito
Copy link
Contributor

Summary

Waterfalls into #1639

Do not update orders that don't belong to the connected wallet

To Test

  1. Place an order and open the link to the Explorer
  2. Switch to a different account
  3. Wait until the order is matched
  • You should NOT get a notification about the order being filled
  • The filled order should not be visible in the activity history
  1. Repeat steps after cancelling and when an order is about to expire
  • There should be no notification for orders not belonging to the connected account

@alfetopito alfetopito self-assigned this Oct 21, 2021
@alfetopito alfetopito requested review from a team October 21, 2021 22:57
@github-actions
Copy link
Contributor

  • 🔭 GP Swap: Gnosis Protocol v2 Swap UI

@MareenG
Copy link

MareenG commented Oct 22, 2021

I encountered some issues while testing.
First I tried with rinkeby and always got the following error message:
Bildschirmfoto 2021-10-22 um 13 18 57
No matter which token pair or account I am using.
Its the same for Xdai

@MareenG
Copy link

MareenG commented Oct 22, 2021

On mainnet it works however there is another issue
For some trades the explorer website didn't update when using the link in the pop up modal. It was stuck in the loading process.
When using the link from recent activities after the order was filled it worked also refreshing the site after a while worked
Bildschirmfoto 2021-10-22 um 13 28 57
Bildschirmfoto 2021-10-22 um 13 35 55

@MareenG
Copy link

MareenG commented Oct 22, 2021

Otherwise it works as expected :)

@elena-zh
Copy link

Hey @alfetopito , great!
I have run several tests in order to check whether #1159 case was accidentally fixed with your changes. Unfortunately, not.
But I think it would be logical to fix it as well due to order confirmation modal remains to be displayed when:

  • change an account
    switch to another account

  • change a network
    hide

Besides, it would be nice to display an order status (expired/filled) when we get back to an account. WDYT?
show again

@alfetopito
Copy link
Contributor Author

@MareenG

I encountered some issues while testing. First I tried with rinkeby and always got the following error message: Bildschirmfoto 2021-10-22 um 13 18 57 No matter which token pair or account I am using. Its the same for Xdai

That's super interesting, will investigate.

For some trades the explorer website didn't update when using the link in the pop up modal. It was stuck in the loading process.
When using the link from recent activities after the order was filled it worked also refreshing the site after a while worked

Since the orderId is the same on both the behaviour seems correct from CowSwap side.
Seems like a loading problem on Explorer side.
Haven't bothered that much since a refresh fixes it, but we for sure could improve that.
Would you mind creating an issue on Explorer issue?


@elena-zh

I have run several tests in order to check whether #1159 case was accidentally fixed with your changes. Unfortunately, not.
But I think it would be logical to fix it as well due to order confirmation modal remains to be displayed when:

I don't fully get what you mean.

Are you suggesting to - when account/network changes - remove all currently displayed toast notifications?

Besides, it would be nice to display an order status (expired/filled) when we get back to an account. WDYT?

I might be misremembering, but I think we had that at first but removed because the user might connect to an account at an undefined amount of time later and get the notifications which might be out of context/no longer relevant.

@alfetopito
Copy link
Contributor Author

@MareenG I couldn't reproduce but I've created this PR in an attempt to fix your issue #1686

Let me know whether it works for you there

@elena-zh
Copy link

Are you suggesting to - when account/network changes - remove all currently displayed toast notifications?

@alfetopito , exactly

I might be misremembering, but I think we had that at first but removed because the user might connect to an account at an undefined amount of time later and get the notifications which might be out of context/no longer relevant.

Hm. I still face them in a mobile view and have been thinking that it is OK. That is why I asked about it.

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.

Nice! looking fw to cherry grab this one!

status: OrderTypeKeys,
order: SerializedOrder
): void {
// Attempt to fix `TypeError: Cannot add property <x>, object is not extensible`
Copy link
Contributor

Choose a reason for hiding this comment

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

I see you got the idea from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Cant_define_property_object_not_extensible

..but, I don't really get it, one reason we use reduxjs/toolkit it's because we can mutate fearlessly the state. Who do you suggest is using preventExtensions?

We have similar logics in all other reducers. Should we be consider with the others? why this is happening now?

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'm not completely sure what was causing it, but this seemed to be the place where issues Mareen was facing came from.
For more context check the PR where this was added #1686
I was not able to reproduce it, but as you can see from the from PR, it seemed that the problem was trying to edit a readonly object.

Copy link
Contributor

Choose a reason for hiding this comment

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

🤷

@alfetopito alfetopito requested a review from anxolin October 27, 2021 22:05
@anxolin anxolin mentioned this pull request Nov 4, 2021
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.

Approving, although the REDUX fix bugs me a bit. It makes me a bit uncofortable to change code without understanding what is happening.

Ideally we would reproduce the case and understand it better, cause maybe this is covering something else 🤷

@alfetopito alfetopito merged commit 2aa2163 into 1334/activity-orders-from-api-rebased Nov 8, 2021
@alfetopito alfetopito deleted the 1334/only-update-connected-wallet branch November 8, 2021 22:49
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
* 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 (gnosis/cowswap#1686)

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

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

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.

4 participants