-
Notifications
You must be signed in to change notification settings - Fork 985
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
base: develop
Are you sure you want to change the base?
Conversation
Signed-off-by: Mohamed Javid <[email protected]>
(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)) |
There was a problem hiding this comment.
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))] |
There was a problem hiding this comment.
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.
(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))})))) |
There was a problem hiding this comment.
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?)}])) |
There was a problem hiding this comment.
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.
Hey @smohamedjavid, would you mind also check and advice about this issue?#21483 also my draft PR #21867 (not working properly yet) |
There was a problem hiding this 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the collectible*
fixes #21727
Summary
This PR fixes
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
Steps to test
Prerequisites: An account with ERC721 and ERC1155 collectibles
ERC721
ERC1155
status: ready