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

[#18736] add address to watch using an ENS #19043

Merged
merged 13 commits into from
Mar 8, 2024

Conversation

ulisesmac
Copy link
Contributor

fixes #18736

Summary

This PR adds the ability to register an address to watch using an ENS, also some some small bugs.
Check the following example, sonnyf.eth exists and sonnyff.eth doesn't exist,.

Before:

Screencast.from.2024-02-28.12-48-32.webm

Now:

Screencast.from.2024-02-28.12-56-16.webm
Screencast.from.2024-02-28.13-11-37.webm

Platforms

  • Android
  • iOS

Steps to test

  • Open Status
  • Navigate to wallet tab
  • Register a new watch account using an ENS (now is possible)
  • Try to register the same ENS, the UI shouldn't allow it.

status: ready

@@ -114,16 +114,15 @@

(defn- local-suggestions-list
[]
(fn []
Copy link
Contributor Author

@ulisesmac ulisesmac Feb 28, 2024

Choose a reason for hiding this comment

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

Just removing an extra fn [] I found, not related to this PR

Comment on lines 14 to 23
(defn validate-message
[addresses]
(fn [s]
(cond
(or (= s nil) (= s "")) nil
(contains? addresses s) (i18n/label :t/address-already-in-use)
(not (or (validation/eth-address? s)
(validation/ens-name? s))) (i18n/label :t/invalid-address)
:else nil)))
(defn- validate-address
[known-addresses s]
(cond
(or (nil? s) (= s "")) nil
(contains? known-addresses s) (i18n/label :t/address-already-in-use)
(not (or (validation/eth-address? s)
(validation/ens-name? s))) (i18n/label :t/invalid-address)))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just changed the function to not return another function, I've seen the previous pattern, although it's completely ok, causes some bugs/confusion while using it

Comment on lines +151 to +162
(if @validation-msg
[quo/info-message
{:accessibility-label :error-message
:size :default
:icon :i/info
:type :error
:style style/info-message}
@validation-msg]
[activity-indicator activity-state])]]))))
Copy link
Contributor Author

@ulisesmac ulisesmac Feb 28, 2024

Choose a reason for hiding this comment

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

This if was a when, while using when, two messages could be displayed under certain circumstances, because we have two components and the back-end response comes some time later.

The message is the following:
image

I think we should only have a single component, having two makes the code more error prone. A bigger refactor on this component might be needed, but I didn't do it here because I wanted to keep the diff focused.

@status-im-auto
Copy link
Member

status-im-auto commented Feb 28, 2024

Jenkins Builds

Click to see older builds (19)
Commit #️⃣ Finished (UTC) Duration Platform Result
49db5ee #2 2024-02-28 19:28:53 ~6 min tests 📄log
f11d730 #4 2024-02-28 19:37:00 ~6 min tests 📄log
✔️ f11d730 #4 2024-02-28 19:37:15 ~6 min android 🤖apk 📲
✔️ f11d730 #4 2024-02-28 19:38:11 ~7 min android-e2e 🤖apk 📲
✔️ f11d730 #4 2024-02-28 19:41:07 ~10 min ios 📱ipa 📲
✔️ 73f0dca #5 2024-02-29 19:52:23 ~7 min android 🤖apk 📲
✔️ 73f0dca #5 2024-02-29 19:52:32 ~7 min android-e2e 🤖apk 📲
✔️ 73f0dca #5 2024-02-29 19:57:25 ~12 min ios 📱ipa 📲
86cc38f #7 2024-03-07 22:00:20 ~1 min tests 📄log
✔️ 86cc38f #7 2024-03-07 22:06:11 ~7 min android 🤖apk 📲
✔️ 86cc38f #7 2024-03-07 22:07:56 ~8 min android-e2e 🤖apk 📲
✔️ 86cc38f #7 2024-03-07 22:11:27 ~12 min ios 📱ipa 📲
✔️ 6a4dd19 #8 2024-03-07 22:32:06 ~7 min android 🤖apk 📲
✔️ 6a4dd19 #8 2024-03-07 22:32:06 ~7 min android-e2e 🤖apk 📲
✔️ 6a4dd19 #8 2024-03-07 22:33:04 ~8 min ios 📱ipa 📲
c7529bb #9 2024-03-08 16:03:40 ~6 min tests 📄log
✔️ c7529bb #9 2024-03-08 16:04:22 ~6 min android 🤖apk 📲
✔️ c7529bb #9 2024-03-08 16:04:59 ~7 min android-e2e 🤖apk 📲
✔️ c7529bb #9 2024-03-08 16:10:24 ~12 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 44b1c6d #10 2024-03-08 16:47:17 ~5 min tests 📄log
✔️ 44b1c6d #10 2024-03-08 16:48:35 ~7 min android-e2e 🤖apk 📲
✔️ 44b1c6d #10 2024-03-08 16:49:06 ~7 min android 🤖apk 📲
✔️ 44b1c6d #10 2024-03-08 16:53:32 ~12 min ios 📱ipa 📲
✔️ 144ca8d #11 2024-03-08 18:13:31 ~5 min tests 📄log
✔️ 144ca8d #11 2024-03-08 18:15:19 ~7 min android 🤖apk 📲
✔️ 144ca8d #11 2024-03-08 18:15:20 ~7 min android-e2e 🤖apk 📲
✔️ 144ca8d #11 2024-03-08 18:19:48 ~11 min ios 📱ipa 📲

@ulisesmac ulisesmac force-pushed the 18736-watch-only-address-by-ens branch from 8227dc2 to f11d730 Compare February 28, 2024 19:30
Comment on lines 358 to 408
(rf/reg-event-fx
:wallet/get-address-details
(fn [{:keys [db]} [address-or-ens]]
(let [request-params [(chain/chain-id db) address-or-ens]
ens? (string/includes? address-or-ens ".")]
{:db (-> db
(assoc-in [:wallet :ui :add-address-to-watch :activity-state] :scanning)
(assoc-in [:wallet :ui :add-address-to-watch :validated-address] nil))
:fx [(if ens?
[:json-rpc/call
[{:method "ens_addressOf"
:params request-params
:on-success [:wallet/get-address-details]
:on-error [:wallet/ens-not-found]}]]
[:json-rpc/call
[{:method "wallet_getAddressDetails"
:params request-params
:on-success [:wallet/store-valid-address-activity address-or-ens]
:on-error #(log/info "failed to get address details"
{:error %
:event :wallet/get-address-details})}]])]})))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Part of the main solution, I'm calling "ens_addressOf" to first resolve the given ens to an address

(defn- validate-address
[known-addresses s]
(cond
(or (nil? s) (= s "")) nil
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: (= s "") --> (string/blank? s)

Copy link
Contributor Author

@ulisesmac ulisesmac Feb 29, 2024

Choose a reason for hiding this comment

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

thanks @ibrkhalil !
Actually, I already tried it, but they are different and I didn't want to change the logic.

blank will say true when it's " " or "\n \n" too, I thought it was cheaper to just comapre it with = and ""

{:db (assoc-in db
[:wallet :ui :watch-address-activity-state]
(if hasActivity :has-activity :no-activity))}))
(rf/reg-event-fx
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, so this file is really starting to bloat.
@OmarBasem, @briansztamfater & I discussed this week of further splitting the wallet into sub-contexts
Mostly based off the figma keys, but we can have others that better fit.
Screenshot 2024-02-29 at 18 30 20

e.g something like

src/status_im/contexts/wallet/
     |-/accounts
         |-/events.cljs
         |-/view.cljs
         |-/style.cljs
      |-/add-account
         |-/events.cljs
         |-/view.cljs
         |-/style.cljs
         |-/create-account
         |-/add-account-to-watch

etc..
We have this for Send & Collectibles already too.

Anyway, I'm not saying to do this refactor here, but perhaps we can at least create the appropriate ns for these events added and move them to that file and the others can be moved in a refactor.

Also maybe these events are common enough to wallet that they should be in this ns. 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@J-Son89
Totally agree!

Actually I noticed this while adding these events, but noticed it's only happening on Collectibles and wasn't sure.
But yeah, I'll move them. mirrorring figma structure is a nice idea 👍

@status-im-auto
Copy link
Member

94% of end-end tests have passed

Total executed tests: 48
Failed tests: 2
Expected to fail tests: 1
Passed tests: 45
IDs of failed tests: 703133,702745 
IDs of expected to fail tests: 703503 

Failed tests (2)

Click to expand
  • Rerun failed tests

  • Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745

    # STEP: Send messages with non-latin symbols
    Device 1: Find `Button` by `accessibility id`: `jump-to`

    critical/chats/test_1_1_public_chats.py:278: in test_1_1_chat_non_latin_messages_stack_update_profile_photo
        self.home_1.jump_to_card_by_text(self.username_2)
    ../views/base_view.py:658: in jump_to_card_by_text
        self.click_on_floating_jump_to()
    ../views/base_view.py:647: in click_on_floating_jump_to
        self.jump_to_button.click()
    ../views/base_element.py:90: in click
        element = self.find_element()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 1: Button by accessibility id: `jump-to` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133

    Device 1: Tap on found: Button
    Device 1: Wait for element Button for max 30s and click when it is available

    critical/chats/test_public_chat_browsing.py:195: in test_restore_multiaccount_with_waku_backup_remove_switch
        self.sign_in.recover_access(passphrase=waku_user.seed, second_user=True)
    ../views/sign_in_view.py:278: in recover_access
        self.identifiers_button.wait_and_click(30)
    ../views/base_element.py:100: in wait_and_click
        self.wait_for_visibility_of_element(sec)
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 1: Button by accessibility id:`skip-identifiers` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Expected to fail tests (1)

    Click to expand

    Class TestCommunityOneDeviceMerged:

    1. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Curated communities not loading, https://github.com//issues/17852]]

    Passed tests (45)

    Click to expand

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_several_images_send_reply, id: 703194
    Device sessions

    2. test_community_one_image_send_reply, id: 702859
    Device sessions

    3. test_community_emoji_send_copy_paste_reply, id: 702840
    Device sessions

    4. test_community_mark_all_messages_as_read, id: 703086
    Device sessions

    5. test_community_contact_block_unblock_offline, id: 702894
    Device sessions

    6. test_community_edit_delete_message_when_offline, id: 704615
    Device sessions

    7. test_community_message_delete, id: 702839
    Device sessions

    8. test_community_message_send_check_timestamps_sender_username, id: 702838
    Device sessions

    9. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844
    Device sessions

    10. test_community_message_edit, id: 702843
    Device sessions

    11. test_community_unread_messages_badge, id: 702841
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    4. test_1_1_chat_edit_message, id: 702855
    Device sessions

    5. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    6. test_1_1_chat_pin_messages, id: 702731
    Device sessions

    7. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_markdown_support, id: 702809
    Device sessions

    2. test_community_hashtag_links_to_community_channels, id: 702948
    Device sessions

    3. test_community_mentions_push_notification, id: 702786
    Device sessions

    4. test_community_leave, id: 702845
    Device sessions

    5. test_community_join_when_node_owner_offline, id: 703629
    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_pin_messages, id: 702732
    Device sessions

    2. test_group_chat_mute_chat, id: 703495
    Device sessions

    3. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    4. test_group_chat_reactions, id: 703202
    Device sessions

    5. test_group_chat_join_send_text_messages_push, id: 702807
    Device sessions

    6. test_group_chat_offline_pn, id: 702808
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_add_contact_field_validation, id: 702777
    Device sessions

    2. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    3. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    Class TestDeepLinksOneDevice:

    1. test_links_open_universal_links_from_chat, id: 704613
    Device sessions

    2. test_links_deep_links, id: 702775
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    Class TestActivityMultipleDevicePR:

    1. test_navigation_jump_to, id: 702936
    Device sessions

    2. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    2. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783
    Device sessions

    3. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    2. test_community_undo_delete_message, id: 702869
    Device sessions

    3. test_community_navigate_to_channel_when_relaunch, id: 702846
    Device sessions

    4. test_community_mute_community_and_channel, id: 703382
    Device sessions

    @VolodLytvynenko VolodLytvynenko self-assigned this Mar 5, 2024
    @VolodLytvynenko
    Copy link
    Contributor

    hey @ulisesmac could you please rebase the current PR and resolve existing conflicts?

    (validation/ens-name? s))) (i18n/label :t/invalid-address)
    :else nil)))
    (defn- validate-address
    [known-addresses s]
    Copy link
    Member

    Choose a reason for hiding this comment

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

    can we have a more descriptive variable name for s?

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    sure

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    done

    @ulisesmac ulisesmac force-pushed the 18736-watch-only-address-by-ens branch from 73f0dca to 4338c5b Compare March 7, 2024 21:57
    @ulisesmac
    Copy link
    Contributor Author

    @VolodLytvynenko I've already rebased and solved the conflicts

    @ulisesmac
    Copy link
    Contributor Author

    @J-Son89 I followed your suggested code structure and pushed the changes

    @status-im-auto
    Copy link
    Member

    96% of end-end tests have passed

    Total executed tests: 48
    Failed tests: 1
    Expected to fail tests: 1
    Passed tests: 46
    
    IDs of failed tests: 702869 
    
    IDs of expected to fail tests: 703503 
    

    Failed tests (1)

    Click to expand
  • Rerun failed tests

  • Class TestCommunityOneDeviceMerged:

    1. test_community_undo_delete_message, id: 702869

    Device 1: Tap on found: Button
    Device 1: Find `Button` by `xpath`: `//*[@text="Undo"]`

    critical/chats/test_public_chat_browsing.py:112: in test_community_undo_delete_message
        self.channel.element_by_text("Undo").click()
    ../views/base_element.py:90: in click
        element = self.find_element()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 1: Button by xpath: `//*[@text="Undo"]` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Device sessions

    Expected to fail tests (1)

    Click to expand

    Class TestCommunityOneDeviceMerged:

    1. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Curated communities not loading, https://github.com//issues/17852]]

    Passed tests (46)

    Click to expand

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133
    Device sessions

    2. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    3. test_community_navigate_to_channel_when_relaunch, id: 702846
    Device sessions

    4. test_community_mute_community_and_channel, id: 703382
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    4. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    5. test_1_1_chat_edit_message, id: 702855
    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    7. test_1_1_chat_pin_messages, id: 702731
    Device sessions

    8. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_pin_messages, id: 702732
    Device sessions

    2. test_group_chat_mute_chat, id: 703495
    Device sessions

    3. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    4. test_group_chat_reactions, id: 703202
    Device sessions

    5. test_group_chat_join_send_text_messages_push, id: 702807
    Device sessions

    6. test_group_chat_offline_pn, id: 702808
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_add_contact_field_validation, id: 702777
    Device sessions

    2. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    3. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    2. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783
    Device sessions

    3. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_several_images_send_reply, id: 703194
    Device sessions

    2. test_community_one_image_send_reply, id: 702859
    Device sessions

    3. test_community_emoji_send_copy_paste_reply, id: 702840
    Device sessions

    4. test_community_mark_all_messages_as_read, id: 703086
    Device sessions

    5. test_community_contact_block_unblock_offline, id: 702894
    Device sessions

    6. test_community_edit_delete_message_when_offline, id: 704615
    Device sessions

    7. test_community_message_delete, id: 702839
    Device sessions

    8. test_community_message_send_check_timestamps_sender_username, id: 702838
    Device sessions

    9. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844
    Device sessions

    10. test_community_message_edit, id: 702843
    Device sessions

    11. test_community_unread_messages_badge, id: 702841
    Device sessions

    Class TestDeepLinksOneDevice:

    1. test_links_open_universal_links_from_chat, id: 704613
    Device sessions

    2. test_links_deep_links, id: 702775
    Device sessions

    Class TestActivityMultipleDevicePR:

    1. test_navigation_jump_to, id: 702936
    Device sessions

    2. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_markdown_support, id: 702809
    Device sessions

    2. test_community_hashtag_links_to_community_channels, id: 702948
    Device sessions

    3. test_community_mentions_push_notification, id: 702786
    Device sessions

    4. test_community_leave, id: 702845
    Device sessions

    5. test_community_join_when_node_owner_offline, id: 703629
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    @VolodLytvynenko
    Copy link
    Contributor

    hi @ulisesmac thank you for PR. No issues from my side. PR is ready to be merged

    @ulisesmac ulisesmac force-pushed the 18736-watch-only-address-by-ens branch from 6a4dd19 to c7529bb Compare March 8, 2024 15:57
    @ulisesmac ulisesmac merged commit 3c69239 into develop Mar 8, 2024
    6 checks passed
    @ulisesmac ulisesmac deleted the 18736-watch-only-address-by-ens branch March 8, 2024 18:20
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Archived in project
    Archived in project
    Development

    Successfully merging this pull request may close these issues.

    The watch only wallet can't be added via ENS
    7 participants