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(network): integrate new rpc providers api #17110

Merged
merged 2 commits into from
Jan 31, 2025

Conversation

dlipicar
Copy link
Contributor

@dlipicar dlipicar commented Jan 21, 2025

What does the PR do

Integrate new RPC Providers API from status-im/status-go#6178
Instead of main/fallback URLs, we now have a list of RPCProviders.

The user cannot replace the default providers, they can only define their own, which get used first.
For this reason, Revert to default (which brought back the default provider urls) no longer makes sense, so the option was removed.

No functional changes for now, designs for new User RPC Provider configuration UI in progress (see https://www.figma.com/design/idUoxN7OIW2Jpp3PMJ1Rl8/%E2%9A%99%EF%B8%8F-Settings-%7C-Desktop?node-id=25452-240238&t=XlKqIWmeeh2smJTT-0), for this reason I tried to touch as little as possible from the UI elements.

Took the chance to tidy up the surrounding code a little bit.

Affected areas

Settings->Wallet->Network

Architecture compliance

Screenshot of functionality (including design for comparison)

  • I've checked the design and this PR matches it

@dlipicar dlipicar requested review from a team, micieslak, caybro and alexjba as code owners January 21, 2025 20:21
@dlipicar dlipicar requested review from Cuteivist and removed request for a team January 21, 2025 20:21
@status-im-auto
Copy link
Member

status-im-auto commented Jan 21, 2025

Jenkins Builds

Click to see older builds (21)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 24002c6 #1 2025-01-21 20:30:33 ~8 min macos/aarch64 🍎dmg
✔️ 24002c6 #1 2025-01-21 20:30:53 ~9 min tests/nim 📄log
✔️ 24002c6 #1 2025-01-21 20:34:09 ~12 min tests/ui 📄log
✔️ 24002c6 #1 2025-01-21 20:37:42 ~16 min macos/x86_64 🍎dmg
✔️ 24002c6 #1 2025-01-21 20:41:14 ~19 min linux/x86_64 📦tgz
✔️ 24002c6 #1 2025-01-21 20:43:10 ~21 min linux-nix/x86_64 📦tgz
✔️ 24002c6 #1 2025-01-21 20:50:12 ~28 min windows/x86_64 💿exe
✔️ 367aa0c #2 2025-01-24 21:30:17 ~8 min tests/nim 📄log
367aa0c #2 2025-01-24 21:30:56 ~9 min tests/ui 📄log
✔️ 367aa0c #2 2025-01-24 21:32:03 ~10 min macos/aarch64 🍎dmg
✔️ 367aa0c #2 2025-01-24 21:34:34 ~12 min macos/x86_64 🍎dmg
✔️ 367aa0c #2 2025-01-24 21:39:25 ~17 min linux/x86_64 📦tgz
✔️ 367aa0c #2 2025-01-24 21:42:28 ~20 min linux-nix/x86_64 📦tgz
✔️ 367aa0c #2 2025-01-24 21:44:37 ~22 min windows/x86_64 💿exe
✔️ d6b036c #4 2025-01-27 14:05:20 ~9 min tests/nim 📄log
✔️ d6b036c #4 2025-01-27 14:06:20 ~10 min macos/aarch64 🍎dmg
d6b036c #4 2025-01-27 14:06:33 ~10 min tests/ui 📄log
✔️ d6b036c #4 2025-01-27 14:13:56 ~18 min macos/x86_64 🍎dmg
✔️ d6b036c #4 2025-01-27 14:14:47 ~19 min linux-nix/x86_64 📦tgz
✔️ d6b036c #4 2025-01-27 14:15:23 ~19 min linux/x86_64 📦tgz
✔️ d6b036c #4 2025-01-27 14:23:02 ~27 min windows/x86_64 💿exe
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 81b808a #5 2025-01-27 14:35:29 ~6 min macos/aarch64 🍎dmg
✔️ 81b808a #5 2025-01-27 14:37:29 ~8 min tests/nim 📄log
✔️ 81b808a #5 2025-01-27 14:41:43 ~12 min macos/x86_64 🍎dmg
✔️ 81b808a #5 2025-01-27 14:42:35 ~13 min tests/ui 📄log
✔️ 81b808a #5 2025-01-27 14:46:15 ~17 min linux/x86_64 📦tgz
✔️ 81b808a #5 2025-01-27 14:46:59 ~18 min linux-nix/x86_64 📦tgz
✔️ 81b808a #5 2025-01-27 14:52:24 ~23 min windows/x86_64 💿exe
✔️ 2f3d731 #6 2025-01-31 14:24:55 ~6 min macos/aarch64 🍎dmg
✔️ 2f3d731 #6 2025-01-31 14:27:46 ~9 min tests/nim 📄log
✔️ 2f3d731 #6 2025-01-31 14:31:36 ~12 min tests/ui 📄log
✔️ 2f3d731 #6 2025-01-31 14:32:29 ~13 min macos/x86_64 🍎dmg
✔️ 2f3d731 #6 2025-01-31 14:38:24 ~19 min linux-nix/x86_64 📦tgz
✔️ 2f3d731 #6 2025-01-31 14:38:46 ~20 min linux/x86_64 📦tgz
✔️ 2f3d731 #6 2025-01-31 14:45:45 ~27 min windows/x86_64 💿exe

Copy link
Contributor

@alexjba alexjba left a comment

Choose a reason for hiding this comment

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

Nice work! LGTM in general!

Two things caught my attention.

return 0
return self.delegate.getFlatNetworksList()[self.index].rpcProviders.len

proc countChanged(self: RpcProvidersModel) {.signal.}
Copy link
Contributor

Choose a reason for hiding this comment

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

count property has proven to be quite problematic. When used in QML we're assuming the nim model will be used in all cases. But that's not true. We can easily need at some point to add a proxy on top and any implementation using count will be broken.

If the model count is needed in qml we can use model.ModelCount.count (ui/StatusQ/include/StatusQ/modelcount.h)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh this is actually not getting used anywhere, shame on me for copypasting. Will remove.


QtObject:
type
Model* = ref object of QAbstractListModel
delegate: io_interface.NetworksDataSource
rpcProvidersPerNetwork: seq[RpcProvidersModel]
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered detaching the nested model from the networks model?
I think it's worth considering a flat RPCProvidersModel outside of the scope of networks model.

When needed in qml we can get the data using a SFPM, filtering per chain. But in most cases it's probably not needed at all.

The nested models are ok if it's used for a single view structure. This means to give up flexibility in favor of convenience. But since there's less flexibility, when the data is needed in another context it's really expensive to process the data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can do! I don't think this is gonna be used in more than 1 place (the network config screen), but it's true that I had to do some workaroundy stuff due to the usage of nested models.

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!

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.

LGTM in general

Global.openTestnetPopup()
checked: root.areTestNetworksEnabled
onToggled:{
checked = Qt.binding(() => root.areTestNetworksEnabled)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, you shouldn't be setting the checked property from the toggled handler 🤔

Copy link
Contributor Author

@dlipicar dlipicar Jan 27, 2025

Choose a reason for hiding this comment

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

hmm the binding should break when the user clicks the button, and we're not sure which value root.areTestNetworksEnabled will end up having (since we open a popup letting the user proceed or cancel the toggle, or something could fail when making the backend call to change this setting). Where would you suggest I put this logic instead?

I guess what we really want is a "Detached Switch" that does not actually change its checked state when the user clicks it (it just emits some event), and has its state set externally instead.

@dlipicar dlipicar requested a review from alexjba January 27, 2025 12:39
@dlipicar dlipicar force-pushed the feat/integrate-new-rpc-providers-api branch 3 times, most recently from d6b036c to 81b808a Compare January 27, 2025 14:28
Copy link
Contributor

@alexjba alexjba left a comment

Choose a reason for hiding this comment

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

Nice!

@dlipicar dlipicar force-pushed the feat/integrate-new-rpc-providers-api branch from 81b808a to 2f3d731 Compare January 31, 2025 14:18
@dlipicar dlipicar merged commit 55e96bb into master Jan 31, 2025
9 checks passed
@dlipicar dlipicar deleted the feat/integrate-new-rpc-providers-api branch January 31, 2025 15:11
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.

4 participants