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

fix(wallet)_: Send flow for collectibles #21871

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

smohamedjavid
Copy link
Member

fixes #21727

Summary

This PR fixes

  • the send flow for collectibles (ERC721 and ERC1155)
  • picking the right balance of the ERC1155 in the send flow from the account page, based on the account viewing by the user
  • the balance of ERC1155 is sometimes incorrect if the collectible is present in more than one account of the user
Collectibles.send.flow.mp4

Testing notes

This PR doesn't fix the balance of the collectible after it's been sent. It's handled in different issue: #21483.

Platforms

  • Android
  • iOS

Steps to test

Prerequisites: An account with ERC721 and ERC1155 collectibles

ERC721

  • Open Status
  • Navigate to Wallet tab > Collectibles
  • Tap on any ERC721 and tap on Send
  • Verify the account of the collectible is automatically selected
  • Verify the user is taken to select the recipient

ERC1155

  • Open Status
  • Navigate to Wallet tab > Collectibles
  • Tap on any ERC155 which is present in two accounts and tap on Send
  • Verify the user is taken to select the account to send from

status: ready

@status-im-auto
Copy link
Member

status-im-auto commented Dec 26, 2024

Jenkins Builds

Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ aa4871e #1 2024-12-26 11:50:42 ~4 min tests 📄log
✔️ aa4871e #1 2024-12-26 11:53:01 ~6 min android-e2e 🤖apk 📲
✔️ aa4871e #1 2024-12-26 11:53:19 ~7 min android 🤖apk 📲
✔️ aa4871e #1 2024-12-26 11:53:43 ~7 min ios 📱ipa 📲

Comment on lines +71 to +80
(defn remove-duplicates-in-ownership
[ownership]
(->> ownership
(reduce (fn [acc {:keys [address timestamp] :as owner}]
(let [existing-owner (get acc address)]
(if (or (nil? existing-owner) (> timestamp (:timestamp existing-owner)))
(assoc acc address owner)
acc)))
{})
vals))
Copy link
Member Author

Choose a reason for hiding this comment

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

Sometimes, the status-go returns duplicate data in the list, we do a cleanup based on the address and timestamp of the balance.

collectible-tx? (send-utils/tx-type-collectible?
(-> db :wallet :ui :send :tx-type))
collectible (when collectible-tx?
(-> db :wallet :ui :send :collectible))
one-collectible? (when collectible-tx?
(= (collectible.utils/collectible-balance collectible) 1))]
(= (collectible.utils/collectible-balance collectible sender) 1))]
Copy link
Member Author

Choose a reason for hiding this comment

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

Picking the right balance of the collectible to send.

Previously, we took the first balance in the list, which may not be the right balance of the selected account.

Comment on lines +260 to +275
(fn [{:keys [db]} [{:keys [ignore-entry-point?]}]]
(let [entry-point-wallet-home? (= (get-in db [:wallet :ui :send :entry-point]) :wallet-stack)
multiple-owners? (get-in db [:wallet :ui :send :collectible-multiple-owners?])
transaction-type (get-in db [:wallet :ui :send :tx-type])]
(when (or ignore-entry-point?
(and entry-point-wallet-home? (not multiple-owners?))
(not entry-point-wallet-home?))
{:db (update-in db
[:wallet :ui :send]
dissoc
:collectible
:collectible-multiple-owners?
:token-display-name
:amount
(when (send-utils/tx-type-collectible? transaction-type)
:tx-type))}))))
Copy link
Member Author

Choose a reason for hiding this comment

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

We skip cleaning the selected collectible on navigating back (the user will land on the From screen) from the select recipient screen if the collectible is present in multiple accounts.

(rf/dispatch [:wallet/select-from-account
{:address address
:network-details network-details
:stack-id :screen/wallet.select-from
:start-flow? true}]))
:start-flow? (not collectible-tx?)}]))
Copy link
Member Author

Choose a reason for hiding this comment

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

If it's a collectible tx, the flow is already started.

@smohamedjavid smohamedjavid marked this pull request as ready for review December 26, 2024 11:57
@mohsen-ghafouri
Copy link
Contributor

Hey @smohamedjavid, would you mind also check and advice about this issue?#21483
when i was testing i notice that :wallet/collectibles-data-updated recieved wrong balance (current balance and not updated data), I also tried to fetch manually after update but that didn't work too, so IMO the only way to fix it in status-go side. wdyt?

also my draft PR #21867 (not working properly yet)

Copy link
Contributor

@mohsen-ghafouri mohsen-ghafouri left a comment

Choose a reason for hiding this comment

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

LGTM

:start-flow? start-flow?
:flow-id :wallet-send-flow}]]]})))
:fx (if
;; If the is present in multiple accounts, the user will be taken to select the address
Copy link
Member

Choose a reason for hiding this comment

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

If the collectible*

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

Successfully merging this pull request may close these issues.

User sees Select assets screen when navigates back to send collectible
4 participants