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

chore(@desktop/wallet): Wallet: explore streamlining "all tokens model" #12489

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

Khushboo-dev-cpp
Copy link
Contributor

@Khushboo-dev-cpp Khushboo-dev-cpp commented Oct 20, 2023

Closes #12424

required go PR : status-im/status-go#4165

What does the PR do

We have tried to analyze the model needed in order to implement the new Manage tokens feature (design in here) and realised we would have to create a copy of the tokens module (wallet->tokens) nested within profile->wallet. At this point we felt the need to re look at the data to check if the way of exposing data to the UI can be streamlined to avoid confusion and code duplication when using the models from the nim backend. Below are the goals and the implementation we did in order to add this improvement.

To summarise, this PR includes the initial implementation of the new design, and, equally important, a proposal for changes/improvements to the approach used so far. The proposed approach is intended to be extended to another areas in the application and, when accepted by the others, assumed as the default approach for new works. For this reason, it is important that the review of this PR is done by as wide group of developers as possible, in order to both obtain a consensus on the changes and alos continue them in subsequent works.

Goal:

SERVICE LAYER

  1. The service class should be the source of truth. Any modules that need same data for its own purpose should refer to the respective service.
  2. The service class should hold data in the simplest format possible, which will hopefully cover future usages of this data set. We tried to understand all the current features that need this data in order to come up with the data structures that allows us to cover most of the feature sets while still focusing on the simplicity of the data set.
  3. The data stored in the service should avoid data filtering in anyway in the service class as this would be a UI responsibility
  4. All clients of this service should only depend on that particular service to "fetch" the data and not hold its own state.

MODEL

  1. Models will not hold its own state but will access the data from the service and also be notified of any updates in order to then notify the UI as well.
  2. Models will simply act as an abstract interface in order to expose the service "data"/ "data structures" to the UI in the required UI format
  3. Create generic models as per feature sets and not specific to any UI screens (not create a separate model for each new UI screen that needs to show same data, represented differently). We will do further transformations using proxy models, ex. SortFilterProxyModel, LeftJoinModel etc... on the UI side.

MODULE

  1. Create as less sub modules as possible that manages the same data source to be shared and used in various "sections" of the UI. This will avoid repetition of code (such as creating instances of different token models in profile, wallet, community etc) and uncertainty when deciding which is the real source of information for different use cases.

QML STORES

  1. Analyse current stores definition and try to create and use single store across all sections of UI. For ex. TokensStore for tokens list (example for this new store in this PR)
  2. Stores will be a good place to create UI specific models which are used in multiple places during the app lifecycle by using the Utility models (SortFilterProxyModel, LeftJoinModels etc). For a specific view's needs, proxies can be used directly in the component.

The ideal structure for our qml stores should be as defined below but in scope of current work we will only do this for the TokensStore as an example:

  • AppMain should instantiate a single RootStore which contains stores for all other "sections" (ex. ProfileStore, CommunityStore, WalletStore..). The "section" store will then contains the stores for its own "sub sections " (ex. WalletStore will instantiate TokenStore, WalletAccountsStore, ActivityStore, TransactionStore etc..)
  • We should definitely avoid singleton stores because they introduce hidden dependencies, problems with initialisation order and hinder testability.

Covered use cases for tokens list:

  1. To add new permission in a community via Holding dropdown.
  2. To validate and avoid repetition of name and symbol whenever a new community token is minted.
  3. To display all tokens from a specific source in Wallet ->Settings.

Implementation:

SERVICE

  1. The service files calls the getTokensList API from status_go on init and creates token lists as mentioned in the next point. It also listens to any updates from status_go and updates itself.

  2. The app_service/token/service.nim contains the below structures:

    • sourcesOfTokensList: seq[SupportedSourcesItem]
      This holds the various sources - Uniswap, Status, Custom, Native

    • flatTokenList: seq[TokenItem]
      This contains a flat list of all non repeating tokens and each holds information about its different sources. ex. DAI's sources will be [Uniswap, Status] as it is available on both lists.
      This sources list contains foreign keys that refer to thekeyof the sourcesOfTokensList.
      The key in this case is the combination of chainID+Address.

    • tokenBySymbolList: seq[TokenBySymbolItem]
      This contains list of tokens grouped by symbol and also contains its various sources.
      In case of community (not done yet) we will not group those by symbol due to the fact that there are scenarios where a community minted token has same symbol as a token from one of the sources list.
      The key in this case is symbol if communityId is nil else the key is the address.

    • tokenDetailsList: Table[string, TokenDetails] (TBD)
      Used to get description and detailed information of the token from crypto compare and will be lazy loaded.

NOTE: All of the the list items mentioned above contain a key property uniquely identifying a particular entry in the list.

  1. The service will emit needed signals when the data is being updated. Ex. SIGNAL_TOKEN_LIST_ABOUT_TO_BE_UPDATED and SIGNAL_TOKEN_LIST_UPDATED (This will be used to update model which is explained later).

MODULE:

  1. The Module used the approach explained here in order to expose an interface to the "Model" class.
  2. The Module exposes the APIs needed in order to read the actual list from the service via this interface.
  3. The module receives the signals (SIGNAL_TOKEN_LIST_ABOUT_TO_BE_UPDATED and SIGNAL_TOKEN_LIST_UPDATED) from the service file (across controller) and converts them into local events for the model, thus reducing the exposure of the Model to many signals that it is not interested in.

MODEL:

  1. The Model contains no seq[Items] within it.
  2. Instead, it calls an api via the Modules interface in order to access any of the items data in the service.

GENERIC PROXY MODELS:

As we want to keep the main models exposed from the backend as simple as possible we need means to do further transformations later, on UI side. It can be done using SortFilterProxyModel library, but in some cases it's not sufficient. For example we need to combine data from two or more models into one model. To handle such case we introduced first two fully reusable and generic proxy models: RoleRenamingModel and LeftJoinModel (#12530). In the future we foresee adding more proxies to cover our needs regarding models transformations.

@status-im-auto
Copy link
Member

status-im-auto commented Oct 20, 2023

Jenkins Builds

Click to see older builds (179)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 554f700 #1 2023-10-20 08:27:02 ~5 min tests/statusq 📄log
554f700 #1 2023-10-20 08:28:17 ~6 min macos/aarch64 📄log
✔️ 554f700 #1 2023-10-20 08:28:40 ~6 min tests/nim 📄log
554f700 #1 2023-10-20 08:29:03 ~7 min macos/x86_64 📄log
✖️ 554f700 #1 2023-10-20 08:30:18 ~8 min tests/e2e 📄log
554f700 #1 2023-10-20 08:31:33 ~9 min linux/x86_64 📄log
554f700 #1 2023-10-20 08:38:56 ~16 min windows/x86_64 📄log
ffdda6d #2 2023-10-20 11:48:43 ~3 min macos/aarch64 📄log
✔️ ffdda6d #2 2023-10-20 11:50:23 ~5 min tests/nim 📄log
✔️ ffdda6d #2 2023-10-20 11:50:25 ~5 min tests/statusq 📄log
✖️ ffdda6d #2 2023-10-20 11:50:54 ~5 min tests/e2e 📄log
ffdda6d #2 2023-10-20 11:52:40 ~7 min linux/x86_64 📄log
ffdda6d #2 2023-10-20 11:52:52 ~7 min macos/x86_64 📄log
ffdda6d #2 2023-10-20 11:56:51 ~11 min windows/x86_64 📄log
d079e47 #3 2023-10-20 13:19:26 ~2 min macos/aarch64 📄log
d079e47 #3 2023-10-20 13:21:30 ~4 min macos/x86_64 📄log
✔️ d079e47 #3 2023-10-20 13:22:39 ~5 min tests/nim 📄log
✖️ d079e47 #3 2023-10-20 13:22:58 ~6 min tests/e2e 📄log
✔️ d079e47 #3 2023-10-20 13:24:08 ~7 min tests/statusq 📄log
d079e47 #3 2023-10-20 13:24:33 ~7 min linux/x86_64 📄log
d079e47 #3 2023-10-20 13:27:19 ~10 min windows/x86_64 📄log
✔️ fc7017b #4 2023-10-23 16:32:04 ~5 min tests/nim 📄log
✔️ fc7017b #4 2023-10-23 16:32:18 ~5 min tests/statusq 📄log
✔️ fc7017b #4 2023-10-23 16:32:43 ~5 min macos/aarch64 🍎dmg
✔️ fc7017b #4 2023-10-23 16:34:54 ~7 min macos/x86_64 🍎dmg
✔️ fc7017b #4 2023-10-23 16:40:46 ~13 min linux/x86_64 📦tgz
✔️ fc7017b #4 2023-10-23 16:48:01 ~20 min windows/x86_64 💿exe
✖️ fc7017b #4 2023-10-23 17:06:44 ~39 min tests/e2e 📄log
✔️ 47510b0 #5 2023-10-23 19:09:04 ~5 min tests/statusq 📄log
✔️ 47510b0 #5 2023-10-23 19:09:18 ~5 min tests/nim 📄log
✔️ 47510b0 #5 2023-10-23 19:09:41 ~5 min macos/aarch64 🍎dmg
✔️ 47510b0 #5 2023-10-23 19:11:33 ~7 min macos/x86_64 🍎dmg
✔️ 47510b0 #5 2023-10-23 19:18:26 ~14 min linux/x86_64 📦tgz
✔️ 47510b0 #5 2023-10-23 19:25:45 ~21 min windows/x86_64 💿exe
✖️ 47510b0 #5 2023-10-23 19:41:39 ~37 min tests/e2e 📄log
✔️ a8ff757 #6 2023-10-24 16:41:31 ~5 min tests/nim 📄log
✔️ a8ff757 #6 2023-10-24 16:42:10 ~5 min macos/aarch64 🍎dmg
✔️ a8ff757 #6 2023-10-24 16:44:09 ~7 min macos/x86_64 🍎dmg
✔️ a8ff757 #6 2023-10-24 16:49:20 ~13 min linux/x86_64 📦tgz
✔️ a8ff757 #6 2023-10-24 16:59:04 ~22 min windows/x86_64 💿exe
✖️ a8ff757 #6 2023-10-24 17:13:32 ~37 min tests/e2e 📄log
✔️ beee047 #7 2023-10-25 09:51:47 ~5 min tests/nim 📄log
✔️ beee047 #7 2023-10-25 09:52:48 ~6 min macos/aarch64 🍎dmg
✔️ beee047 #7 2023-10-25 09:54:19 ~7 min macos/x86_64 🍎dmg
✔️ beee047 #7 2023-10-25 10:01:06 ~14 min linux/x86_64 📦tgz
✔️ beee047 #7 2023-10-25 10:05:24 ~18 min windows/x86_64 💿exe
✖️ beee047 #7 2023-10-25 10:31:07 ~44 min tests/e2e 📄log
✔️ 457be84 #10 2023-10-25 12:36:56 ~5 min tests/nim 📄log
✔️ 457be84 #10 2023-10-25 12:38:25 ~7 min macos/x86_64 🍎dmg
✔️ 457be84 #10 2023-10-25 12:38:45 ~7 min macos/aarch64 🍎dmg
457be84 #1 2023-10-25 12:42:43 ~11 min tests/ui 📄log
✔️ 457be84 #10 2023-10-25 12:45:37 ~14 min linux/x86_64 📦tgz
✔️ 457be84 #10 2023-10-25 12:49:53 ~18 min windows/x86_64 💿exe
✖️ 457be84 #10 2023-10-25 12:55:56 ~25 min tests/e2e 📄log
✔️ e18f20c #12 2023-10-25 17:36:07 ~5 min tests/nim 📄log
✔️ e18f20c #12 2023-10-25 17:36:24 ~5 min macos/aarch64 🍎dmg
✔️ e18f20c #12 2023-10-25 17:39:32 ~8 min macos/x86_64 🍎dmg
e18f20c #3 2023-10-25 17:41:04 ~10 min tests/ui 📄log
✔️ e18f20c #12 2023-10-25 17:45:38 ~14 min linux/x86_64 📦tgz
✖️ e18f20c #12 2023-10-25 17:55:06 ~24 min tests/e2e 📄log
✔️ e18f20c #12 2023-10-25 18:05:35 ~34 min windows/x86_64 💿exe
✔️ 96baeee #13 2023-10-27 14:52:43 ~5 min tests/nim 📄log
✔️ 96baeee #13 2023-10-27 14:53:41 ~6 min macos/aarch64 🍎dmg
✔️ 96baeee #13 2023-10-27 14:55:54 ~8 min macos/x86_64 🍎dmg
96baeee #4 2023-10-27 14:57:26 ~10 min tests/ui 📄log
✔️ 96baeee #13 2023-10-27 15:01:37 ~14 min linux/x86_64 📦tgz
✔️ 96baeee #13 2023-10-27 15:08:34 ~21 min windows/x86_64 💿exe
✖️ 96baeee #13 2023-10-27 15:24:59 ~37 min tests/e2e 📄log
✔️ aa3778b #14 2023-10-30 14:57:41 ~5 min tests/nim 📄log
✔️ aa3778b #14 2023-10-30 15:00:35 ~8 min macos/x86_64 🍎dmg
aa3778b #5 2023-10-30 15:03:02 ~11 min tests/ui 📄log
✔️ aa3778b #14 2023-10-30 15:07:20 ~15 min linux/x86_64 📦tgz
✔️ aa3778b #14 2023-10-30 15:13:13 ~21 min windows/x86_64 💿exe
✖️ aa3778b #14 2023-10-30 15:34:38 ~42 min tests/e2e 📄log
✔️ 3131339 #15 2023-10-30 15:56:01 ~11 min macos/x86_64 🍎dmg
✔️ 3131339 #15 2023-10-30 15:59:10 ~14 min tests/nim 📄log
✔️ 3131339 #15 2023-10-30 16:02:31 ~17 min linux/x86_64 📦tgz
✔️ 3131339 #15 2023-10-30 16:04:21 ~19 min windows/x86_64 💿exe
3131339 #6 2023-10-30 16:05:05 ~20 min tests/ui 📄log
✖️ 3131339 #15 2023-10-30 16:29:39 ~44 min tests/e2e 📄log
✔️ 3131339 #15 2023-10-30 16:36:01 ~51 min macos/aarch64 🍎dmg
✔️ 3aae10e #16 2023-11-02 17:27:01 ~9 min macos/x86_64 🍎dmg
✔️ 3aae10e #16 2023-11-02 17:31:27 ~14 min linux/x86_64 📦tgz
✔️ 3ddfcbf #17 2023-11-02 17:41:00 ~5 min macos/aarch64 🍎dmg
✔️ 3ddfcbf #17 2023-11-02 17:42:28 ~7 min macos/x86_64 🍎dmg
✔️ 80d842c #18 2023-11-03 13:49:48 ~5 min macos/aarch64 🍎dmg
✔️ 80d842c #18 2023-11-03 13:54:48 ~10 min macos/x86_64 🍎dmg
✔️ 80d842c #9 2023-11-03 13:54:55 ~10 min tests/ui 📄log
✔️ 80d842c #18 2023-11-03 13:57:41 ~13 min linux/x86_64 📦tgz
✔️ 80d842c #18 2023-11-03 14:07:59 ~23 min windows/x86_64 💿exe
✖️ 80d842c #18 2023-11-03 14:28:16 ~43 min tests/e2e 📄log
✔️ 04c4777 #20 2023-11-03 14:41:04 ~7 min macos/aarch64 🍎dmg
04c4777 #11 2023-11-03 14:42:23 ~9 min tests/ui 📄log
✔️ 04c4777 #20 2023-11-03 14:45:54 ~12 min macos/x86_64 🍎dmg
✔️ 04c4777 #20 2023-11-03 14:51:24 ~18 min linux/x86_64 📦tgz
✖️ 04c4777 #20 2023-11-03 15:17:16 ~44 min tests/e2e 📄log
✔️ 52c00fc #21 2023-11-07 14:42:40 ~5 min macos/aarch64 🍎dmg
✔️ 52c00fc #21 2023-11-07 14:42:57 ~6 min tests/nim 📄log
✔️ 52c00fc #21 2023-11-07 14:45:30 ~8 min macos/x86_64 🍎dmg
✔️ 52c00fc #12 2023-11-07 14:52:54 ~16 min tests/ui 📄log
✔️ 52c00fc #21 2023-11-07 14:53:37 ~16 min linux/x86_64 📦tgz
✔️ f4e27cf #22 2023-11-07 15:07:45 ~7 min macos/aarch64 🍎dmg
✔️ f4e27cf #22 2023-11-07 15:09:02 ~9 min macos/x86_64 🍎dmg
✔️ f4e27cf #22 2023-11-07 15:13:19 ~13 min tests/nim 📄log
✔️ f4e27cf #22 2023-11-07 15:20:06 ~20 min linux/x86_64 📦tgz
✔️ f4e27cf #13 2023-11-07 15:21:23 ~21 min tests/ui 📄log
✔️ 8e942c7 #25 2023-11-07 15:48:41 ~5 min macos/aarch64 🍎dmg
✔️ 8e942c7 #25 2023-11-07 15:49:01 ~5 min tests/nim 📄log
✔️ 11d07bf #27 2023-11-07 15:59:32 ~5 min macos/aarch64 🍎dmg
✔️ 11d07bf #27 2023-11-07 15:59:55 ~6 min tests/nim 📄log
✔️ 11d07bf #27 2023-11-07 16:01:06 ~7 min macos/x86_64 🍎dmg
✔️ 11d07bf #18 2023-11-07 16:04:42 ~11 min tests/ui 📄log
✔️ 11d07bf #27 2023-11-07 16:10:14 ~16 min linux/x86_64 📦tgz
a36f1d7 #28 2023-11-07 16:13:58 ~2 min macos/aarch64 📄log
a36f1d7 #28 2023-11-07 16:15:32 ~3 min macos/x86_64 📄log
✖️ a36f1d7 #28 2023-11-07 16:17:14 ~5 min tests/e2e 📄log
a36f1d7 #28 2023-11-07 16:18:49 ~7 min linux/x86_64 📄log
a36f1d7 #28 2023-11-07 16:22:08 ~10 min windows/x86_64 📄log
✔️ a36f1d7 #19 2023-11-07 16:22:15 ~10 min tests/ui 📄log
✔️ 98e3788 #29 2023-11-08 16:57:09 ~5 min macos/aarch64 🍎dmg
✔️ 98e3788 #29 2023-11-08 17:00:09 ~8 min macos/x86_64 🍎dmg
✔️ 98e3788 #20 2023-11-08 17:03:04 ~11 min tests/ui 📄log
✔️ 98e3788 #29 2023-11-08 17:06:14 ~14 min linux/x86_64 📦tgz
✔️ 98e3788 #29 2023-11-08 17:14:26 ~22 min windows/x86_64 💿exe
✖️ 98e3788 #29 2023-11-08 17:30:54 ~38 min tests/e2e 📄log
✔️ 56ea0f9 #30 2023-11-08 22:41:14 ~5 min macos/aarch64 🍎dmg
✔️ 56ea0f9 #30 2023-11-08 22:43:55 ~8 min macos/x86_64 🍎dmg
✔️ 56ea0f9 #21 2023-11-08 22:46:34 ~10 min tests/ui 📄log
✔️ 56ea0f9 #30 2023-11-08 22:49:42 ~13 min linux/x86_64 📦tgz
✔️ 56ea0f9 #30 2023-11-08 22:57:07 ~21 min windows/x86_64 💿exe
✖️ 56ea0f9 #30 2023-11-08 23:13:58 ~38 min tests/e2e 📄log
✔️ dfb875d #31 2023-11-13 17:41:48 ~5 min tests/nim 📄log
✔️ dfb875d #31 2023-11-13 17:41:48 ~5 min macos/aarch64 🍎dmg
✔️ dfb875d #31 2023-11-13 17:45:57 ~9 min macos/x86_64 🍎dmg
✔️ dfb875d #22 2023-11-13 17:48:33 ~11 min tests/ui 📄log
✔️ dfb875d #31 2023-11-13 17:49:56 ~13 min linux/x86_64 📦tgz
✔️ dfb875d #31 2023-11-13 17:59:12 ~22 min windows/x86_64 💿exe
✔️ 36db2e7 #32 2023-11-13 18:06:52 ~4 min macos/aarch64 🍎dmg
✔️ 36db2e7 #32 2023-11-13 18:07:24 ~5 min tests/nim 📄log
✔️ 36db2e7 #32 2023-11-13 18:09:19 ~7 min macos/x86_64 🍎dmg
✔️ 36db2e7 #23 2023-11-13 18:15:49 ~13 min tests/ui 📄log
✔️ 36db2e7 #32 2023-11-13 18:17:14 ~15 min linux/x86_64 📦tgz
✔️ 36db2e7 #32 2023-11-13 18:27:57 ~25 min windows/x86_64 💿exe
✖️ 36db2e7 #32 2023-11-13 18:50:02 ~48 min tests/e2e 📄log
✔️ d73fc31 #33 2023-11-14 09:56:48 ~5 min tests/nim 📄log
✔️ d73fc31 #33 2023-11-14 09:58:42 ~7 min macos/aarch64 🍎dmg
✔️ d73fc31 #33 2023-11-14 10:00:10 ~8 min macos/x86_64 🍎dmg
✔️ d73fc31 #24 2023-11-14 10:02:38 ~11 min tests/ui 📄log
✔️ d73fc31 #33 2023-11-14 10:05:35 ~14 min linux/x86_64 📦tgz
✖️ d73fc31 #33 2023-11-14 10:12:50 ~21 min tests/e2e 📄log
✔️ d051678 #34 2023-11-14 10:30:32 ~5 min tests/nim 📄log
✔️ d051678 #34 2023-11-14 10:32:44 ~7 min macos/x86_64 🍎dmg
✔️ d051678 #34 2023-11-14 10:32:57 ~8 min macos/aarch64 🍎dmg
✔️ d051678 #25 2023-11-14 10:36:59 ~12 min tests/ui 📄log
✔️ d051678 #34 2023-11-14 10:39:25 ~14 min linux/x86_64 📦tgz
✔️ d051678 #34 2023-11-14 10:50:19 ~25 min windows/x86_64 💿exe
✖️ d051678 #34 2023-11-14 10:52:32 ~27 min tests/e2e 📄log
✔️ 09b15fb #35 2023-11-14 11:53:20 ~6 min tests/nim 📄log
✔️ 09b15fb #35 2023-11-14 11:59:24 ~12 min macos/x86_64 🍎dmg
✔️ 09b15fb #35 2023-11-14 11:59:42 ~12 min macos/aarch64 🍎dmg
✔️ baaa06f #36 2023-11-14 12:07:07 ~6 min tests/nim 📄log
✔️ baaa06f #36 2023-11-14 12:11:33 ~10 min macos/x86_64 🍎dmg
✔️ baaa06f #27 2023-11-14 12:12:11 ~11 min tests/ui 📄log
✔️ baaa06f #36 2023-11-14 12:12:39 ~11 min macos/aarch64 🍎dmg
✔️ baaa06f #36 2023-11-14 12:15:14 ~14 min linux/x86_64 📦tgz
✔️ baaa06f #37 2023-11-14 12:23:16 ~20 min windows/x86_64 💿exe
✖️ baaa06f #36 2023-11-14 12:32:18 ~31 min tests/e2e 📄log
✔️ baaa06f #37 2023-11-14 13:17:17 ~31 min tests/e2e 📄log
✔️ 355eee1 #38 2023-11-15 08:14:19 ~6 min tests/nim 📄log
✔️ 355eee1 #38 2023-11-15 08:16:33 ~8 min macos/x86_64 🍎dmg
✔️ 355eee1 #38 2023-11-15 08:19:19 ~11 min macos/aarch64 🍎dmg
✔️ 355eee1 #29 2023-11-15 08:19:36 ~12 min tests/ui 📄log
✔️ 355eee1 #38 2023-11-15 08:21:42 ~14 min linux/x86_64 📦tgz
355eee1 #41 2023-11-15 08:27:55 ~52 sec windows/x86_64 📄log
355eee1 #43 2023-11-15 08:33:15 ~53 sec windows/x86_64 📄log
355eee1 #45 2023-11-15 08:36:49 ~51 sec windows/x86_64 📄log
✖️ 355eee1 #39 2023-11-15 08:39:16 ~31 min tests/e2e 📄log
355eee1 #47 2023-11-15 08:42:58 ~52 sec windows/x86_64 📄log
355eee1 #49 2023-11-15 08:46:38 ~53 sec windows/x86_64 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
8b287f6 #51 2023-11-15 08:51:05 ~52 sec windows/x86_64 📄log
58ce5e1 #53 2023-11-15 08:56:44 ~1 min windows/x86_64 📄log
✔️ 58ce5e1 #40 2023-11-15 08:58:20 ~4 min tests/nim 📄log
✔️ 58ce5e1 #40 2023-11-15 09:01:53 ~8 min macos/aarch64 🍎dmg
✔️ 58ce5e1 #40 2023-11-15 09:05:25 ~11 min macos/x86_64 🍎dmg
✔️ 58ce5e1 #31 2023-11-15 09:05:27 ~11 min tests/ui 📄log
✔️ 58ce5e1 #40 2023-11-15 09:08:32 ~14 min linux/x86_64 📦tgz
✔️ 58ce5e1 #42 2023-11-15 09:24:01 ~30 min tests/e2e 📄log

@Khushboo-dev-cpp Khushboo-dev-cpp force-pushed the chore/12424 branch 8 times, most recently from b9fc737 to 457be84 Compare October 25, 2023 12:30
@Khushboo-dev-cpp Khushboo-dev-cpp changed the title chore(@desktop/wallet): Wallet: explore streamlining "all tokens mode… chore(@desktop/wallet): Wallet: explore streamlining "all tokens model" Oct 25, 2023
@Khushboo-dev-cpp
Copy link
Contributor Author

Khushboo-dev-cpp commented Oct 30, 2023

@everyone who will be reviewing the approach please note that these changes are just to get everyone to agree on the approach only after which will we meet all the goals we have listed above. For now we have created new services and module in order to showcase the changes and is not perfect in terms of code review yet.

Type
# only be valid if source is custom
CommunityId
# everything below should be lazy loaded
Copy link
Collaborator

Choose a reason for hiding this comment

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

I do not see where this is being loaded

Copy link
Contributor

Choose a reason for hiding this comment

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

That's correct. It's a TODO and if we agree that this should be a lazy load, there will be an async method in the service, with the corresponding signal notifications and needed apis in the controller / module / model.

src/app/modules/main/wallet_section/new_tokens/view.nim Outdated Show resolved Hide resolved
Copy link
Contributor

@stefandunca stefandunca left a comment

Choose a reason for hiding this comment

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

Great job. I like the one source of truth approach and shared service data by all the models.

I am still not sure of the following aspects.

  • not sure of modelmodule's purpose given that we don't lazy load modules. A simpler classic MVVM/MVC patterns would simplify code; Controller/View and Model being directly exposed to QML and access service for data as described.
    • also, the io_interface abstraction could be postponed until we have a second implementation and make the dependency more explicit and direct.
  • the use of broadcasting (events) for changes from service to view instead of direct dependency through interfaces or callbacks using DI?

@Khushboo-dev-cpp
Copy link
Contributor Author

Khushboo-dev-cpp commented Oct 31, 2023

Great job. I like the one source of truth approach and shared service data by all the models.

I am still not sure of the following aspects.

  • not sure of model's purpose given that we don't lazy load modules. A simpler classic MVVM/MVC patterns would simplify code; Controller/View and Model being directly exposed to QML and access service for data as described.

Do you mean that model should be directly exposed to the UI instead of the module? this part is not very clear to me.

  • also, the io_interface abstraction could be postponed until we have a second implementation and make the dependency more explicit and direct.
  • the use of broadcasting (events) for changes from service to view instead of direct dependency through interfaces or callbacks using DI?

Here we are trying to showcase a way that there is a direct connection between service and model and we've protected it by introducing the interfaces. Passing the signal via view/module is still possible, however it will be the same we did so far in that case. However interface will be needed to make call to the service api still.

@stefandunca please find questions/reasoning inline above

@micieslak
Copy link
Member

Thank you @stefandunca for your input!

I going to try address your points, but not sure if I fully understand your points:

  • not sure of model's purpose given that we don't lazy load modules. A simpler classic MVVM/MVC patterns would simplify code; Controller/View and Model being directly exposed to QML and access service for data as described.

I'm not sure if you really mean model's. Imo the purpose is clear because we really need them in current form as they implement QAbstractItemModel which is nice way of communication between nim and qml.

  • also, the io_interface abstraction could be postponed until we have a second implementation and make the dependency more explicit and direct.

Yes, it's true that now it's kind of boilerplate code. And probably we will never have second implementations here. But having those interfaces modules are testable bc we can mock their dependencies (because they depend on abstractions). And again, I know we don't have those tests. But we really should... so I would opt for at least keeping possibility of testing here.

  • the use of broadcasting (events) for changes from service to view instead of direct dependency through interfaces or callbacks using DI?

Here, first, I'm not sure what DI is (?). But in general the motivation was to deliberately keep that dependency as explicit as possible instead of hiding it in implementation details were listening to signals is implemented. And it's done regarding API for reading data by the model, but still needs to be improved regarding notifications from services which are handled internally in the model.

Anyways, I'm really happy that in general we are on the same page. Regarding your concerns - I hope I'm adding some explanation here. If not, I think we could (or even should) try to clarify via further discussion to have clear mutual understanding here :)

@stefandunca
Copy link
Contributor

stefandunca commented Nov 1, 2023

I'm not sure if you really mean model's. Imo the purpose is clear because we really need them in current form as they implement QAbstractItemModel which is nice way of communication between nim and qml.

I'm sorry for the confusion, I meant module. Thanks for the heads up.

Yes, it's true that now it's kind of boilerplate code. And probably we will never have second implementations here. But having those interfaces modules are testable bc we can mock their dependencies (because they depend on abstractions). And again, I know we don't have those tests. But we really should... so I would opt for at least keeping possibility of testing here.

I agree with you that it would be great if we had a usage for this abstraction instead of making the code harder to follow and maintain. I wanted to find out if I'm the only one who finds it harder to follow the code due to those abstractions.

Another reason for dropping them is that in one of our desktop meetings, I raised the need for nim tests, and the answer was that we don't want to invest time given that C++ is so close and it will bring the tests to the presentation layer.

Here, first, I'm not sure what DI is (?).

I mean dependency injection. Basically (pass interfaces/callbacks) instead of assuming that implementation will listen to some required broadcasted messages.

But in general the motivation was to deliberately keep that dependency as explicit as possible instead of hiding it in implementation details were listening to signals is implemented. And it's done regarding API for reading data by the model, but still needs to be improved regarding notifications from services which are handled internally in the model.

The highlighted text is exactly what I asked, why not direct clear dependency through instances/callbacks instead of message broker broadcasted signals which makes it hard to understand which implementation depends on which signals that come from where? Events are a runtime aspect and not compile time aspects like interfaces/instances/callbacks.

Anyways, I'm really happy that in general we are on the same page. Regarding your concerns - I hope I'm adding some explanation here. If not, I think we could (or even should) try to clarify via further discussion to have clear mutual understanding here :)

It is more of a curiosity, I didn't dive deep in the implementation to see if there are some limitations on applying the simplifications I propose. Thanks for taking the time to share your thoughts.

Copy link
Member

@micieslak micieslak left a comment

Choose a reason for hiding this comment

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

Looks nice in general. Only some minor remarks. I'm blocking bc of the auto-login.

What is interesting is this:
Screenshot from 2023-11-10 16-47-33

Sometimes icons are all black, sometimes all are ok 🤔

ui/app/AppLayouts/Onboarding/views/LoginView.qml Outdated Show resolved Hide resolved
ui/app/AppLayouts/Wallet/stores/TokensStore.qml Outdated Show resolved Hide resolved
ui/app/AppLayouts/Wallet/stores/TokensStore.qml Outdated Show resolved Hide resolved
ui/app/AppLayouts/Wallet/stores/TokensStore.qml Outdated Show resolved Hide resolved
storybook/pages/TokenListPopupPage.qml Outdated Show resolved Hide resolved
Copy link
Contributor

@noeliaSD noeliaSD left a comment

Choose a reason for hiding this comment

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

Great job!

I've just left some suggestions/comments. Otherwise, LGTM!

Now.. going to test the branch!

src/app/modules/main/communities/module.nim Show resolved Hide resolved
src/app_service/service/token/service_items.nim Outdated Show resolved Hide resolved
src/app_service/service/token/service_items.nim Outdated Show resolved Hide resolved
ui/app/AppLayouts/Wallet/stores/TokensStore.qml Outdated Show resolved Hide resolved
ui/app/AppLayouts/Wallet/stores/TokensStore.qml Outdated Show resolved Hide resolved
@noeliaSD
Copy link
Contributor

Looks nice in general. Only some minor remarks. I'm blocking bc of the auto-login.

What is interesting is this: Screenshot from 2023-11-10 16-47-33

Sometimes icons are all black, sometimes all are ok 🤔

I'd say we can create a sperate task to investigate this..

@Khushboo-dev-cpp
Copy link
Contributor Author

Khushboo-dev-cpp commented Nov 13, 2023

Looks nice in general. Only some minor remarks. I'm blocking bc of the auto-login.
What is interesting is this: Screenshot from 2023-11-10 16-47-33
Sometimes icons are all black, sometimes all are ok 🤔

I'd say we can create a sperate task to investigate this..

#12718 created this one, makes sense to do it separately!

@status-im-auto
Copy link
Member

Copy link
Contributor

@noeliaSD noeliaSD left a comment

Choose a reason for hiding this comment

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

@Khushboo-dev-cpp thanks for addressing the comments!

I've just tested the branch and I can see all listed tokens in the new Tokens List tab settings section!

@Khushboo-dev-cpp Khushboo-dev-cpp marked this pull request as ready for review November 14, 2023 15:06
Copy link
Member

@caybro caybro left a comment

Choose a reason for hiding this comment

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

Massive work! Just 2 questions :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wallet: explore streamlining the various wallet models spread across different sections
10 participants