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

feat: add ability to tap to disable from networks in send & bridge flow #19392

Merged
merged 1 commit into from
Apr 15, 2024

Conversation

briansztamfater
Copy link
Member

@briansztamfater briansztamfater commented Mar 25, 2024

fixes #18655
fixes #19440

Summary

Well, this PR turned to be larger than I wanted to be, but I think it is worth it.

The main purpose of this PR is to adds the ability for the user to disable sender networks when tapping a network on the "From" column in the Send or Bridge flow.

For example, this enables a way for the user to select the "From" network when bridging. The steps would be:

  • First, wait for the best route to load
  • Then, disable the unwanted chain(s) and wait for the new route to be loaded

Alternatively, user can re-enable the network by tapping again on it.

Demo video of the main added feature:

disablechains.mp4

Now, about what additionally included in this PR:

  • Moved logic to calculate the total amount sent from / to for each chain, that was previously on transaction confirmation view to events namespace, so we can now subscribe to the data that is needed also when showing suggested routes. New related subs are :wallet/wallet-send-from-values-by-chain and :wallet/wallet-send-to-values-by-chain.
  • Worked on a refactor of Network Link component, which was not resizable and was causing UI issues. This implied rebuilding SVG composition to have a static part in the middle, and stretchable parts at the side.
Before After
Stretchable Network Link Demo
networklinkdemo.mp4

Platforms

  • Android
  • iOS

Areas that maybe impacted

Functional
  • wallet / transactions

Steps to test

  • Open Status
  • Login with an account with some funds
  • Go to wallet
  • Select the account
  • Tap on Send
  • Select a receiver address
  • Select a token where you have balances on more than one chain
  • Input an amount
  • Wait for routes to be loaded. If there is no issues with entered amount and owned balances, suggested routes will show.
  • Tap a route network on the From column to disable it. If there is only one available chain for the token and amount, disable won't work.
  • Wait for new route to be loaded without the disabled network.
  • Additionally, tap the disabled network in the From column to re-enable it.

status: ready

@status-im-auto
Copy link
Member

status-im-auto commented Mar 25, 2024

Jenkins Builds

Click to see older builds (167)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 2b925b2 #1 2024-03-25 18:39:48 ~6 min android 🤖apk 📲
✔️ 2b925b2 #1 2024-03-25 18:40:25 ~7 min tests 📄log
✔️ 2b925b2 #1 2024-03-25 18:40:56 ~7 min android-e2e 🤖apk 📲
✔️ 2b925b2 #1 2024-03-25 18:42:51 ~9 min ios 📱ipa 📲
✔️ 45e6a84 #2 2024-03-25 19:12:19 ~6 min tests 📄log
✔️ 45e6a84 #2 2024-03-25 19:12:26 ~6 min android 🤖apk 📲
✔️ 45e6a84 #2 2024-03-25 19:13:06 ~7 min android-e2e 🤖apk 📲
✔️ 45e6a84 #2 2024-03-25 19:15:20 ~9 min ios 📱ipa 📲
1263e5c #3 2024-03-26 20:17:30 ~1 min tests 📄log
✔️ 1263e5c #3 2024-03-26 20:23:02 ~6 min android-e2e 🤖apk 📲
✔️ 1263e5c #3 2024-03-26 20:23:23 ~7 min android 🤖apk 📲
✔️ 1263e5c #3 2024-03-26 20:37:50 ~21 min ios 📱ipa 📲
facb7cf #4 2024-03-27 03:54:12 ~53 sec tests 📄log
✔️ facb7cf #4 2024-03-27 04:00:22 ~7 min android 🤖apk 📲
✔️ facb7cf #4 2024-03-27 04:00:24 ~7 min android-e2e 🤖apk 📲
✔️ facb7cf #4 2024-03-27 04:02:46 ~9 min ios 📱ipa 📲
509d4fb #5 2024-03-27 04:04:15 ~1 min tests 📄log
✔️ 509d4fb #5 2024-03-27 04:09:21 ~6 min android 🤖apk 📲
✔️ 509d4fb #5 2024-03-27 04:09:23 ~6 min android-e2e 🤖apk 📲
✔️ 509d4fb #5 2024-03-27 04:11:24 ~8 min ios 📱ipa 📲
cea5662 #6 2024-03-27 15:07:27 ~1 min tests 📄log
✔️ cea5662 #6 2024-03-27 15:13:23 ~7 min android 🤖apk 📲
✔️ cea5662 #6 2024-03-27 15:13:28 ~7 min android-e2e 🤖apk 📲
✔️ cea5662 #6 2024-03-27 15:14:30 ~8 min ios 📱ipa 📲
33b5e50 #7 2024-03-27 20:56:05 ~1 min tests 📄log
✔️ 33b5e50 #7 2024-03-27 21:01:02 ~6 min android-e2e 🤖apk 📲
✔️ 33b5e50 #7 2024-03-27 21:01:09 ~6 min android 🤖apk 📲
✔️ 33b5e50 #7 2024-03-27 21:04:39 ~9 min ios 📱ipa 📲
5199876 #8 2024-03-27 21:14:31 ~1 min tests 📄log
✔️ 5199876 #8 2024-03-27 21:19:37 ~6 min android 🤖apk 📲
✔️ 5199876 #8 2024-03-27 21:19:59 ~6 min android-e2e 🤖apk 📲
✔️ 5199876 #8 2024-03-27 21:22:49 ~9 min ios 📱ipa 📲
c46a283 #9 2024-03-28 02:59:57 ~1 min tests 📄log
✔️ c46a283 #9 2024-03-28 03:04:44 ~6 min android-e2e 🤖apk 📲
✔️ c46a283 #9 2024-03-28 03:05:20 ~6 min android 🤖apk 📲
✔️ c46a283 #9 2024-03-28 03:08:14 ~9 min ios 📱ipa 📲
e76df78 #10 2024-03-28 18:55:13 ~1 min tests 📄log
✔️ e76df78 #10 2024-03-28 19:00:59 ~7 min android-e2e 🤖apk 📲
✔️ e76df78 #10 2024-03-28 19:01:06 ~7 min android 🤖apk 📲
✔️ e76df78 #10 2024-03-28 19:02:23 ~8 min ios 📱ipa 📲
341b6f1 #11 2024-03-28 19:13:13 ~1 min tests 📄log
✔️ 341b6f1 #11 2024-03-28 19:18:08 ~6 min android 🤖apk 📲
✔️ 341b6f1 #11 2024-03-28 19:18:21 ~6 min android-e2e 🤖apk 📲
✔️ 341b6f1 #11 2024-03-28 19:20:25 ~8 min ios 📱ipa 📲
f22ca46 #12 2024-03-28 19:35:03 ~1 min tests 📄log
✔️ f22ca46 #12 2024-03-28 19:39:30 ~6 min android 🤖apk 📲
✔️ f22ca46 #12 2024-03-28 19:39:59 ~6 min android-e2e 🤖apk 📲
✔️ f22ca46 #12 2024-03-28 19:41:36 ~8 min ios 📱ipa 📲
5f2ea84 #13 2024-03-29 19:40:44 ~1 min tests 📄log
✔️ 5f2ea84 #13 2024-03-29 19:45:43 ~6 min android 🤖apk 📲
✔️ 5f2ea84 #13 2024-03-29 19:45:51 ~6 min android-e2e 🤖apk 📲
✔️ 5f2ea84 #13 2024-03-29 19:48:34 ~8 min ios 📱ipa 📲
a7fb5dc #14 2024-03-29 23:01:27 ~52 sec tests 📄log
✔️ a7fb5dc #14 2024-03-29 23:07:39 ~7 min android-e2e 🤖apk 📲
✔️ a7fb5dc #14 2024-03-29 23:07:45 ~7 min android 🤖apk 📲
✔️ a7fb5dc #14 2024-03-29 23:08:58 ~8 min ios 📱ipa 📲
518f0a2 #15 2024-04-02 05:24:27 ~1 min tests 📄log
d29a79b #16 2024-04-02 05:28:07 ~2 min tests 📄log
✔️ d29a79b #16 2024-04-02 05:33:11 ~7 min android-e2e 🤖apk 📲
✔️ d29a79b #16 2024-04-02 05:33:21 ~8 min android 🤖apk 📲
✔️ d29a79b #16 2024-04-02 05:34:59 ~9 min ios 📱ipa 📲
b0edb0f #17 2024-04-02 06:02:18 ~2 min tests 📄log
✔️ b0edb0f #17 2024-04-02 06:07:03 ~6 min android-e2e 🤖apk 📲
✔️ b0edb0f #17 2024-04-02 06:07:10 ~6 min android 🤖apk 📲
✔️ b0edb0f #17 2024-04-02 06:08:38 ~8 min ios 📱ipa 📲
fab45ea #18 2024-04-02 06:13:55 ~2 min tests 📄log
✔️ fab45ea #18 2024-04-02 06:18:43 ~6 min android-e2e 🤖apk 📲
✔️ fab45ea #18 2024-04-02 06:18:51 ~6 min android 🤖apk 📲
✔️ fab45ea #18 2024-04-02 06:20:09 ~8 min ios 📱ipa 📲
bb5e2a9 #19 2024-04-02 17:22:07 ~2 min tests 📄log
✔️ bb5e2a9 #19 2024-04-02 17:25:45 ~6 min android 🤖apk 📲
✔️ bb5e2a9 #19 2024-04-02 17:26:32 ~7 min android-e2e 🤖apk 📲
✔️ bb5e2a9 #19 2024-04-02 17:27:54 ~8 min ios 📱ipa 📲
0c82517 #20 2024-04-02 17:43:50 ~2 min tests 📄log
✔️ 0c82517 #20 2024-04-02 17:47:14 ~5 min android 🤖apk 📲
✔️ 0c82517 #20 2024-04-02 17:47:41 ~6 min android-e2e 🤖apk 📲
✔️ 0c82517 #20 2024-04-02 17:49:56 ~8 min ios 📱ipa 📲
213c6fe #21 2024-04-02 18:47:22 ~4 min tests 📄log
✔️ 213c6fe #21 2024-04-02 18:50:03 ~6 min android-e2e 🤖apk 📲
✔️ 213c6fe #21 2024-04-02 18:52:59 ~9 min android 🤖apk 📲
e37c2ef #22 2024-04-02 19:14:45 ~2 min tests 📄log
✔️ e37c2ef #22 2024-04-02 19:19:04 ~6 min android 🤖apk 📲
✔️ e37c2ef #22 2024-04-02 19:19:07 ~6 min android-e2e 🤖apk 📲
✔️ e37c2ef #22 2024-04-02 19:58:09 ~45 min ios 📱ipa 📲
✔️ acf3972 #23 2024-04-03 00:37:40 ~4 min tests 📄log
✔️ dabdce6 #24 2024-04-03 00:42:42 ~4 min tests 📄log
✔️ 12fbba8 #25 2024-04-03 00:47:04 ~4 min tests 📄log
✔️ 12fbba8 #25 2024-04-03 00:50:43 ~7 min android-e2e 🤖apk 📲
✔️ 12fbba8 #25 2024-04-03 00:50:54 ~8 min android 🤖apk 📲
✔️ 12fbba8 #25 2024-04-03 00:51:03 ~8 min ios 📱ipa 📲
a12d342 #27 2024-04-03 01:02:08 ~2 min tests 📄log
ea7db86 #28 2024-04-03 01:04:39 ~2 min tests 📄log
✔️ ea7db86 #28 2024-04-03 01:08:56 ~6 min android-e2e 🤖apk 📲
✔️ ea7db86 #28 2024-04-03 01:09:02 ~6 min android 🤖apk 📲
✔️ ea7db86 #28 2024-04-03 01:10:54 ~8 min ios 📱ipa 📲
c4103b9 #29 2024-04-03 01:34:08 ~2 min tests 📄log
✔️ c4103b9 #29 2024-04-03 01:37:10 ~5 min android-e2e 🤖apk 📲
✔️ c4103b9 #29 2024-04-03 01:38:15 ~6 min android 🤖apk 📲
5565d4a #30 2024-04-03 01:41:03 ~2 min tests 📄log
✔️ 5565d4a #30 2024-04-03 01:45:28 ~6 min android-e2e 🤖apk 📲
✔️ 5565d4a #30 2024-04-03 01:45:32 ~6 min android 🤖apk 📲
✔️ 5565d4a #30 2024-04-03 01:47:07 ~8 min ios 📱ipa 📲
bd53bbf #31 2024-04-03 01:50:29 ~2 min tests 📄log
✔️ bd53bbf #31 2024-04-03 01:54:49 ~6 min android-e2e 🤖apk 📲
✔️ bd53bbf #31 2024-04-03 01:54:53 ~6 min android 🤖apk 📲
✔️ bd53bbf #31 2024-04-03 01:56:29 ~8 min ios 📱ipa 📲
✔️ 5fc2394 #32 2024-04-03 03:23:43 ~4 min tests 📄log
✔️ 5fc2394 #32 2024-04-03 03:26:00 ~6 min android 🤖apk 📲
✔️ 5fc2394 #32 2024-04-03 03:26:21 ~6 min android-e2e 🤖apk 📲
✔️ 5fc2394 #32 2024-04-03 03:28:05 ~8 min ios 📱ipa 📲
✔️ 06b2edf #33 2024-04-03 04:22:54 ~3 min tests 📄log
✔️ 06b2edf #33 2024-04-03 04:25:59 ~6 min android-e2e 🤖apk 📲
✔️ 06b2edf #33 2024-04-03 04:26:04 ~6 min android 🤖apk 📲
✔️ 06b2edf #33 2024-04-03 04:27:41 ~8 min ios 📱ipa 📲
✔️ 71e1810 #34 2024-04-03 04:38:34 ~3 min tests 📄log
✔️ 71e1810 #34 2024-04-03 04:41:35 ~6 min android-e2e 🤖apk 📲
✔️ 71e1810 #34 2024-04-03 04:41:42 ~6 min android 🤖apk 📲
✔️ 71e1810 #34 2024-04-03 04:43:19 ~8 min ios 📱ipa 📲
✔️ af74803 #35 2024-04-03 05:02:15 ~3 min tests 📄log
✔️ af74803 #35 2024-04-03 05:05:19 ~6 min android-e2e 🤖apk 📲
✔️ af74803 #35 2024-04-03 05:05:26 ~6 min android 🤖apk 📲
✔️ af74803 #35 2024-04-03 05:06:49 ~8 min ios 📱ipa 📲
✔️ 4555caa #36 2024-04-08 04:28:32 ~4 min tests 📄log
✔️ 4555caa #36 2024-04-08 04:30:29 ~6 min android 🤖apk 📲
✔️ 4555caa #36 2024-04-08 04:31:05 ~6 min android-e2e 🤖apk 📲
✔️ 4555caa #36 2024-04-08 04:32:59 ~8 min ios 📱ipa 📲
a768091 #37 2024-04-08 21:29:09 ~2 min tests 📄log
29a5cf5 #38 2024-04-08 21:32:37 ~2 min tests 📄log
✔️ 29a5cf5 #38 2024-04-08 21:35:56 ~5 min android-e2e 🤖apk 📲
✔️ 29a5cf5 #38 2024-04-08 21:37:13 ~6 min android 🤖apk 📲
✔️ 29a5cf5 #38 2024-04-08 21:38:42 ~8 min ios 📱ipa 📲
✔️ 111d880 #39 2024-04-09 05:20:12 ~4 min tests 📄log
✔️ 111d880 #39 2024-04-09 05:22:43 ~6 min android-e2e 🤖apk 📲
✔️ 111d880 #39 2024-04-09 05:22:45 ~6 min android 🤖apk 📲
✔️ 111d880 #39 2024-04-09 05:24:44 ~8 min ios 📱ipa 📲
f763c5f #40 2024-04-09 15:05:54 ~2 min tests 📄log
✔️ f763c5f #40 2024-04-09 15:10:33 ~6 min android-e2e 🤖apk 📲
✔️ f763c5f #40 2024-04-09 15:10:42 ~6 min android 🤖apk 📲
✔️ f763c5f #40 2024-04-09 15:15:02 ~11 min ios 📱ipa 📲
✔️ 411df35 #41 2024-04-09 15:27:05 ~4 min tests 📄log
✔️ 411df35 #41 2024-04-09 15:30:53 ~8 min android-e2e 🤖apk 📲
✔️ 411df35 #41 2024-04-09 15:30:59 ~8 min android 🤖apk 📲
✔️ 411df35 #41 2024-04-09 15:31:18 ~8 min ios 📱ipa 📲
✔️ 63fd2a1 #44 2024-04-09 20:20:32 ~6 min android 🤖apk 📲
✔️ 63fd2a1 #44 2024-04-09 20:21:41 ~7 min android-e2e 🤖apk 📲
✔️ 63fd2a1 #44 2024-04-09 20:25:41 ~11 min ios 📱ipa 📲
✔️ 13460f4 #45 2024-04-09 22:45:59 ~4 min tests 📄log
✔️ 13460f4 #45 2024-04-09 22:47:40 ~5 min android 🤖apk 📲
✔️ 13460f4 #45 2024-04-09 22:48:39 ~6 min android-e2e 🤖apk 📲
✔️ 13460f4 #45 2024-04-09 22:51:27 ~9 min ios 📱ipa 📲
7a28ba7 #46 2024-04-09 23:15:21 ~2 min tests 📄log
✔️ 7a28ba7 #46 2024-04-09 23:19:51 ~7 min android-e2e 🤖apk 📲
✔️ 7a28ba7 #46 2024-04-09 23:20:33 ~7 min android 🤖apk 📲
✔️ 7a28ba7 #46 2024-04-09 23:21:17 ~8 min ios 📱ipa 📲
edd75be #47 2024-04-09 23:27:02 ~2 min tests 📄log
f8c7de1 #48 2024-04-09 23:33:31 ~2 min tests 📄log
✔️ f8c7de1 #48 2024-04-09 23:36:51 ~6 min android 🤖apk 📲
✔️ f8c7de1 #48 2024-04-09 23:37:30 ~6 min android-e2e 🤖apk 📲
✔️ f8c7de1 #48 2024-04-09 23:39:14 ~8 min ios 📱ipa 📲
✔️ 0eabc7b #49 2024-04-10 03:36:16 ~4 min tests 📄log
✔️ 0eabc7b #49 2024-04-10 03:38:02 ~6 min android-e2e 🤖apk 📲
✔️ 0eabc7b #49 2024-04-10 03:38:54 ~6 min android 🤖apk 📲
✔️ 0eabc7b #49 2024-04-10 03:40:31 ~8 min ios 📱ipa 📲
✔️ a9b4e37 #50 2024-04-11 16:05:27 ~3 min tests 📄log
✔️ a9b4e37 #50 2024-04-11 16:07:10 ~5 min android-e2e 🤖apk 📲
✔️ a9b4e37 #50 2024-04-11 16:07:18 ~5 min android 🤖apk 📲
✔️ a9b4e37 #50 2024-04-11 16:09:50 ~8 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
0888038 #51 2024-04-15 07:31:53 ~3 min tests 📄log
✔️ 0888038 #51 2024-04-15 07:33:40 ~5 min android-e2e 🤖apk 📲
✔️ 0888038 #51 2024-04-15 07:34:56 ~6 min android 🤖apk 📲
✔️ 0888038 #51 2024-04-15 07:38:17 ~10 min ios 📱ipa 📲
✔️ 0888038 #53 2024-04-15 10:07:33 ~3 min tests 📄log
✔️ ee5669c #54 2024-04-15 15:00:04 ~3 min tests 📄log
✔️ ee5669c #52 2024-04-15 15:02:58 ~6 min android 🤖apk 📲
✔️ ee5669c #52 2024-04-15 15:02:58 ~6 min android-e2e 🤖apk 📲
✔️ ee5669c #52 2024-04-15 15:04:31 ~8 min ios 📱ipa 📲

@briansztamfater briansztamfater force-pushed the feat/disable-from-chains branch 5 times, most recently from bd53bbf to 5fc2394 Compare April 3, 2024 03:19
@briansztamfater briansztamfater changed the title [WIP] feat: add ability to tap to disable from networks in send & bridge flow feat: add ability to tap to disable from networks in send & bridge flow Apr 3, 2024
@briansztamfater briansztamfater marked this pull request as ready for review April 3, 2024 04:39
@J-Son89
Copy link
Contributor

J-Son89 commented Apr 3, 2024

@status-im/wallet-mobile-devs - this is the sort of pr that will definitely benefit from one of us doing a quick manual test on.
Would someone like to volunteer to do a quick 5/10 minute test on the functionality? 🙏

:stroke source-color}]
[svg/path
{:d
"M62.9999 1L53.6356 1C42.5899 1 33.6356 9.9543 33.6356 21L33.6356 93C33.6356 104.046 24.6813 113 13.6356 113L5.71778e-05 113"
Copy link
Contributor

Choose a reason for hiding this comment

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

SVG's confuse the hell out of me 😅 . Is there any way to comment the general idea behind these line-1x and line2x views to give some understanding of how this should work, or how you came up with this? 🙏

Copy link
Member Author

Choose a reason for hiding this comment

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

It's basically the d value from the exported SVG from Figma. We need to use it as a base and extend it by code to make it stretchable.

@@ -446,6 +446,8 @@
(def ^:const optimism-short-name "opt")
(def ^:const arbitrum-short-name "arb1")

(def ^:const default-address-prefix "eth:opt:arb1:")
Copy link
Contributor

Choose a reason for hiding this comment

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

so in Status Go this is referred to as:
:prod-preferred-chain-ids
and in the design it's generally referred to as
"network-preferences".

I think we should be consistent in our language for concepts across the codebase.

Imo address-prefix does not suggest the use case and so I prefer the use of default-network-preference or
default-network-preferences-prefix.

cc @OmarBasem, @shivekkhurana, @smohamedjavid as I think we were having the same discussion in another pr.
I don't mind which we choose but let's at least be consistent across usages 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, I don't have a strong opinion on this, I can change it to whatever name we agree on!

Copy link
Contributor

@OmarBasem OmarBasem Apr 3, 2024

Choose a reason for hiding this comment

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

@J-Son89 I don't mind using another name, but we need to differentiate between the current user's network preferences, and the "address prefix" of a receiver when sending tokens (which is network preferences of the receiver not the sender)

Copy link
Contributor

Choose a reason for hiding this comment

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

Both network-preferences and address-prefix are valid names here. The former from the backend perspective, and latter from UI perspective.

But I see this leaking in multiple PR. I have introduced these methods to encapsulate them:

(defn chain-ids->address-prefix [chain-ids])

(defn chain-short-ids->address-prefix [chain-short-ids])

(defn address-prefix->chain-ids [adress-prefix])

(defn address-prefix->chain-short-ids [address-prefix])```

There will probably be a few more to manage all use-cases.

@@ -20,3 +20,44 @@
expected-eip1559-disabled-result (money/bignumber 0.000760406)]
(is (money/equal-to (utils/calculate-gas-fee data-eip1559-disabled)
expected-eip1559-disabled-result))))))

(deftest test-find-affordable-networks
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏

(rf/reg-event-fx
:wallet/select-send-address
(fn [{:keys [db]} [{:keys [address recipient stack-id start-flow?]}]]
(let [[prefix to-address] (utils/split-prefix-and-address address)
test-net? (get-in db [:profile/profile :test-networks-enabled?])
goerli-enabled? (get-in db [:profile/profile :is-goerli-enabled?])
prefix (if (string/blank? prefix) constants/default-address-prefix prefix)
Copy link
Contributor

@J-Son89 J-Son89 Apr 3, 2024

Choose a reason for hiding this comment

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

hmm, prefix is a bit generic imo. Can we make this more descriptive. multi-chain-prefix maybe? 🤔

Also I wonder can we abstract the below code into some utility?

e,g resolve-network-preferences? 🤔
I mean this code block btw.

prefix              (if (string/blank? prefix) constants/default-address-prefix prefix)
prefix-seq          (string/split prefix #":")
selected-networks   (->> prefix-seq
                                  (remove string/blank?)
                                  (mapv #(utils/short-name->id (keyword %) test-net? goerli-enabled?)))

(debounce/debounce-and-dispatch
[:wallet/get-suggested-routes {:amount @input-value}]
2000)
(if (= bounce-duration-ms 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, perhaps you can comment to why this is necessary?

(rn/use-mount
(fn []
(let [dismiss-keyboard-fn #(when (= % "active") (rn/dismiss-keyboard!))
app-keyboard-listener (.addEventListener rn/app-state "change" dismiss-keyboard-fn)]
#(.remove app-keyboard-listener))))
(rn/use-effect
#(fetch-routes input-num-value (current-limit))
#(when (> (count affordable-networks) 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we really need two use-effects?

Copy link
Member Author

Choose a reason for hiding this comment

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

I initially reused the same useEffect, but then I found we need different bounce durations when changing disabled networks than when changing the input amount.

{:margin-top 8
(defn routes-inner-container
[first-item?]
{:margin-top (if first-item? 7.5 11)
Copy link
Contributor

Choose a reason for hiding this comment

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

do we use .5 margins? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah there are many places, it can be sometimes noticeable depending on the device dpi. In this case is because of this:

{:flex 0.5
:margin-left margin-left})
(def section-label-right
{:width 135})
Copy link
Contributor

Choose a reason for hiding this comment

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

why are we hardcoding width? 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

It is fixed width in Figma.

Spacing will vary thanks to :justify-content :space-between in the container (

)

{token-balance :total-balance
token-symbol :symbol
token-networks :networks
token-balances-per-chain :balances-per-chain
Copy link
Contributor

Choose a reason for hiding this comment

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

actually this is something we should avoid,

please see my pr here:

#19568

Basically the issue here is that this file is now creating two sets of the same data, one in the account and one in the send data model. It is better to keep one source of truth so we should store the minimum here and instead look up the account balances based off the send token symbol.

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @ulisesmac as it's something to consider about the data model. We should probably be sure to watch out for this in other places where we can be duplicating some parts of the db

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, and I agree. Maybe we can filter :balances-per-chain and other sensible props from :wallet/wallet-send-token sub to avoid unwanted bugs.

Anyways, just updated the code to use :balances-per-chain from the same sub of your PR 👍

[data chain-id loading-suggested-routes?]
(let [network (utils/id->network chain-id)
new-item-priority (network-priority network)]
(or (->> data
Copy link
Contributor

Choose a reason for hiding this comment

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

what is data here btw?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, some leftover, I updated with more descriptive naming for functions and variables!

(defn- find-insertion-index
[data chain-id loading-suggested-routes?]
(let [network (utils/id->network chain-id)
new-item-priority (network-priority network)]
Copy link
Contributor

Choose a reason for hiding this comment

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

same for item, can we be more descriptive?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

@@ -1,5 +1,8 @@
(ns status-im.contexts.wallet.send.utils
Copy link
Contributor

Choose a reason for hiding this comment

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

what's the difference between wallet/common/utils/send and this one?

I see that the files can have different uses, but is there a pattern we are following?

Copy link
Member Author

Choose a reason for hiding this comment

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

The difference lies in their scope of use: wallet/common/utils/send likely contains utility functions used broadly across the wallet application, while the other is specialized for use within the sibling namespaces (in this case in events.cljs). Open to move it of course!

Copy link
Contributor

Choose a reason for hiding this comment

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

Nope that sounds perfect! 🙌🏼

Copy link
Contributor

@J-Son89 J-Son89 left a comment

Choose a reason for hiding this comment

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

looks good but the total balances issue has to be resolved, otherwise we are introducing another bug for sure :)

and addressing the utils would be nice here as it's a common issue that's starting to rack up in the wallet code 👌

@briansztamfater
Copy link
Member Author

Thanks for the re-review @J-Son89! I pushed some changes and think I covered all the feedback. Let me know if you find anything else!

@briansztamfater briansztamfater force-pushed the feat/disable-from-chains branch from f8c7de1 to 0eabc7b Compare April 10, 2024 03:31
@J-Son89
Copy link
Contributor

J-Son89 commented Apr 11, 2024

@status-im/mobile-qa - can you prioritise this pr over other wallet pr's? 🙏
This pr has some pretty important functionality for the multichain sending pieces 🚀

@briansztamfater briansztamfater force-pushed the feat/disable-from-chains branch 2 times, most recently from a9b4e37 to 0888038 Compare April 15, 2024 07:27
@VolodLytvynenko VolodLytvynenko self-assigned this Apr 15, 2024
@VolodLytvynenko
Copy link
Contributor

hi @briansztamfater thank you for PR. On issue is found. But, it's okay if it will be better to fix it in a separate follow-up. Let me know if this will be addressed in this PR, otherwise, the PR can be merged

ISSUE 1: The routes are not found when entered data is changed

Steps:

  1. Recover the user with assets on at least 2 networks.
  2. Enter a value available for 2 networks (e.g., 0.01 ETH on Mainnet and 0.01 ETH on Optimism, enter 0.01 ETH).
  3. Disable the Mainnet network.
  4. Clear the value in the input field and enter a new value (e.g., 0.2 ETH).

Actual result:

The route searching is not performed

routes_f.mp4

Expected result:

Potential solutions:

  • All routes should be found again, even if a route was disabled in a previous attempt, because a new entered value should trigger new route searching.
  • Disabled routes should be shown as disabled, informing the user that they entered an available amount, but the route for the disabled network is not accessible.

@status-im-auto
Copy link
Member

0% of end-end tests have passed

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

Failed tests (2)

Click to expand
  • Rerun failed tests

  • Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230

    Device 2: Find `Text` by `xpath`: `//android.view.ViewGroup[@content-desc='container']/android.widget.TextView[@text='Ether']/../android.widget.TextView[3]`
    Device 2: `Text` is `0.0116 ETH`

    critical/test_wallet.py:126: in test_wallet_send_asset_from_drawer
        self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
    critical/test_wallet.py:97: in _check_balances_after_tx
        self.errors.verify_no_errors()
    base_test_case.py:190: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Eth amount in the senders wallet is 0.1344 but should be 0.1343
    E    Eth amount in the receivers wallet is 0.0116 but should be 0.0117
    



    Device sessions

    2. test_wallet_send_eth, id: 727229

    Device 2: Find Text by xpath: //android.view.ViewGroup[@content-desc='container']/android.widget.TextView[@text='Ether']/../android.widget.TextView[3]
    Device 2: Text is 0.0116 ETH

    critical/test_wallet.py:111: in test_wallet_send_eth
        self._check_balances_after_tx(amount_to_send, sender_balance, receiver_balance, eth_amount_sender,
    critical/test_wallet.py:97: in _check_balances_after_tx
        self.errors.verify_no_errors()
    base_test_case.py:190: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Eth amount in the senders wallet is 0.1344 but should be 0.1343
    E    Eth amount in the receivers wallet is 0.0116 but should be 0.0117
    



    Device sessions

    @briansztamfater
    Copy link
    Member Author

    briansztamfater commented Apr 15, 2024

    Hi @VolodLytvynenko , thanks for testing! Let's merge this PR first and I can work on that issue on a follow up PR. Let me know if you created the issue or I can create it if you want. Thanks!

    @briansztamfater briansztamfater force-pushed the feat/disable-from-chains branch from 0888038 to ee5669c Compare April 15, 2024 14:55
    @briansztamfater briansztamfater merged commit 98d4969 into develop Apr 15, 2024
    6 checks passed
    @briansztamfater briansztamfater deleted the feat/disable-from-chains branch April 15, 2024 15:04
    @VolodLytvynenko
    Copy link
    Contributor

    Hi @briansztamfater thanx! just created #19650

    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.

    Routes found when exceeded assets value is entered Wallet: Disable "From" networks in send & bridge flow
    9 participants