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

don't buy what is no longer for sale #58

Closed
AltiMario opened this issue Sep 19, 2024 · 5 comments · Fixed by #59
Closed

don't buy what is no longer for sale #58

AltiMario opened this issue Sep 19, 2024 · 5 comments · Fixed by #59
Assignees

Comments

@AltiMario
Copy link
Contributor

AltiMario commented Sep 19, 2024

There is one issue in the frontend as it shows Kitties that already have been bought still as "for sale" so the UI support you in creating a TX to buy this even though it has just been bought and is actually no longer for sale. These transactions fail and it doesn't change the owner again.

@AltiMario AltiMario converted this from a draft issue Sep 19, 2024
@AltiMario
Copy link
Contributor Author

It bug was discovered by the reviewer w3f/Grant-Milestone-Delivery#1170 (comment)

@AltiMario
Copy link
Contributor Author

I just tested again and the anomaly is confirmed.
I would consider it a flaw in business logic.

@nrutledge
Copy link
Collaborator

@AltiMario I tested as well and noticed that the kitty doesn't just remain on sale in the fronted, the backend continues to have it marked for sale after the transfer of ownership. However, it can be purchased as expected when switching accounts (after refreshing the page).

A quick fix would be to optimistically update the kitty on the frontend so that the owner updates immediately after the purchase transaction is submitted. This would prevent someone from seeing the option to buy after they've already purchased. However, this approach has a couple limitations:

  1. If the user refreshes the page (as they might be inclined to do) before the transaction is complete and backend updated, stale data might be fetched, allowing the user to see the option to buy again.
  2. If the transaction fails for any reason, the frontend will still show that the kitty transferred owners when it didn't in reality (until the page is refreshed).

A more robust solution would be to update the backend logic so that the kitty is marked as not for sale after a purchase, and to also improve communication between backend and frontend, such that things remain in a pending status while transactions are being confirmed, update afterwards, etc. But I assume that is out of scope for now.

Would you like me to proceed with the simple optimistic update on the frontend?

@AltiMario
Copy link
Contributor Author

hi @nrutledge I believe fixing the frontend first is the best approach. Well done on sharing the concerns 1 and 2.
Should this frontend fix not meet the reviewer expectations, we can then address the backend without affecting the frontend changes.
Is it correct?

@nrutledge
Copy link
Collaborator

@AltiMario that's correct, the backend changes wouldn't conflict directly with the frontend changes. However, for now I would just optimistically update the owner and not the "for sale" status (to be consistent with current backend behavior). After fixing on the backend, there would just be a slight discrepancy with the status, but it would go away on refresh.

I'll create a PR with the frontend change today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants