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

Merged
merged 1 commit into from
Jan 2, 2025

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

Click to see older builds (4)
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 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 84bedc6 #2 2024-12-31 14:14:59 ~4 min tests 📄log
✔️ 84bedc6 #2 2024-12-31 14:17:03 ~6 min android-e2e 🤖apk 📲
✔️ 84bedc6 #2 2024-12-31 14:17:23 ~6 min android 🤖apk 📲
✔️ 84bedc6 #2 2024-12-31 14:17:39 ~7 min ios 📱ipa 📲
✔️ c679008 #3 2025-01-02 18:06:25 ~4 min tests 📄log
✔️ c679008 #3 2025-01-02 18:08:50 ~6 min android-e2e 🤖apk 📲
✔️ c679008 #3 2025-01-02 18:08:58 ~6 min ios 📱ipa 📲
✔️ c679008 #3 2025-01-02 18:09:03 ~7 min android 🤖apk 📲

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

@VolodLytvynenko VolodLytvynenko self-assigned this Dec 30, 2024
@status-im-auto
Copy link
Member

62% of end-end tests have passed

Total executed tests: 8
Failed tests: 3
Expected to fail tests: 0
Passed tests: 5
IDs of failed tests: 727230,727229,703133 

Failed tests (3)

Click to expand
  • Rerun failed tests

  • Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230

    Device 1: Could not reach wallet view by pressing system back button
    Balance is Invalid API Key (#err2)|ARBTESTNET Gwei

    critical/test_wallet.py:163: in test_wallet_send_asset_from_drawer
        sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx()
    critical/test_wallet.py:38: in _get_balances_before_tx
        sender_balance = self.network_api.get_balance(self.sender['wallet_address'])
    ../support/api/network_api.py:55: in get_balance
        return int(balance) / 1000000000000000000
     invalid literal for int() with base 10: 'Invalid API Key (#err2)|ARBTESTNET'
    



    2. test_wallet_send_eth, id: 727229

    Device 2: Tap on found: Button
    Balance is Invalid API Key (#err2)|ARBTESTNET Gwei

    critical/test_wallet.py:129: in test_wallet_send_eth
        sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx()
    critical/test_wallet.py:38: in _get_balances_before_tx
        sender_balance = self.network_api.get_balance(self.sender['wallet_address'])
    ../support/api/network_api.py:55: in get_balance
        return int(balance) / 1000000000000000000
     invalid literal for int() with base 10: 'Invalid API Key (#err2)|ARBTESTNET'
    



    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_profile_switch, id: 703133

    Device 1: Tap on found: Button
    # STEP: Check that removed user is not shown in the list anymore

    critical/chats/test_public_chat_browsing.py:240: in test_restore_multiaccount_with_waku_backup_remove_profile_switch
        self.errors.verify_no_errors()
    base_test_case.py:209: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     zQ3...dWXh5 was not restored as a contact from waku backup!
    



    Device sessions

    Passed tests (5)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    2. test_wallet_balance_mainnet, id: 740490

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843
    Device sessions

    @VolodLytvynenko VolodLytvynenko removed their assignment Dec 30, 2024
    @smohamedjavid smohamedjavid force-pushed the fix/send-collectibles-flow branch from aa4871e to 84bedc6 Compare December 31, 2024 14:10
    @status-im-auto
    Copy link
    Member

    75% of end-end tests have passed

    Total executed tests: 8
    Failed tests: 0
    Expected to fail tests: 2
    Passed tests: 6
    
    IDs of expected to fail tests: 727230,727229 
    

    Expected to fail tests (2)

    Click to expand

    Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230

    Device 1: Could not reach Button by pressing system back button
    Balance is Invalid API Key (#err2)|ARBTESTNET Gwei

    critical/test_wallet.py:165: in test_wallet_send_asset_from_drawer
        sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx()
    critical/test_wallet.py:38: in _get_balances_before_tx
        sender_balance = self.network_api.get_balance(self.sender['wallet_address'])
    ../support/api/network_api.py:55: in get_balance
        return int(balance) / 1000000000000000000
     invalid literal for int() with base 10: 'Invalid API Key (#err2)|ARBTESTNET' 
    

    [[Arbiscan API is down, looking for analogue]]

    2. test_wallet_send_eth, id: 727229

    Device 2: Tap on found: Button
    Balance is Invalid API Key (#err2)|ARBTESTNET Gwei

    critical/test_wallet.py:130: in test_wallet_send_eth
        sender_balance, receiver_balance, eth_amount_sender, eth_amount_receiver = self._get_balances_before_tx()
    critical/test_wallet.py:38: in _get_balances_before_tx
        sender_balance = self.network_api.get_balance(self.sender['wallet_address'])
    ../support/api/network_api.py:55: in get_balance
        return int(balance) / 1000000000000000000
     invalid literal for int() with base 10: 'Invalid API Key (#err2)|ARBTESTNET' 
    

    [[Arbiscan API is down, looking for analogue]]

    Passed tests (6)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    2. test_wallet_balance_mainnet, id: 740490

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_message_edit, id: 702843
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    2. test_restore_multiaccount_with_waku_backup_remove_profile_switch, id: 703133
    Device sessions

    Comment on lines +8 to +12
    ([{:keys [ownership]} address]
    (let [balance (some #(when (= address (:address %))
    (js/parseInt (:balance %)))
    ownership)]
    (if (js/Number.isNaN balance) 0 balance))))
    Copy link
    Member

    Choose a reason for hiding this comment

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

    There's a helper for parsing numbers that allows to pass a default utils.number/parse-int

    @VolodLytvynenko
    Copy link
    Contributor

    hi @smohamedjavid thank you for PR. Unfortunately, one issue has been found, but it's okay if it will be fixed in a separate follow-up. Let me know if this will be addressed in this PR, otherwise, the PR can be merged
    PR_ISSUE 1: #21882

    @smohamedjavid
    Copy link
    Member Author

    @VolodLytvynenko - I will fix it in a follow-up PR 👍

    @smohamedjavid smohamedjavid force-pushed the fix/send-collectibles-flow branch from 84bedc6 to c679008 Compare January 2, 2025 18:01
    @smohamedjavid smohamedjavid merged commit baf3b8c into develop Jan 2, 2025
    5 checks passed
    @smohamedjavid smohamedjavid deleted the fix/send-collectibles-flow branch January 2, 2025 18:10
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Status: DONE
    Development

    Successfully merging this pull request may close these issues.

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