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

Network Refactor #431

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

panleone
Copy link
Member

Abstract

Objects that inherits from the virtual class Network should only define the corresponding virtual methods, without adding any additional logic.

Currently we have only a Network realization, ExplorerNetwork, that however contained also a lot of additional logic like: safe fetching, retryWrapper, rpc calls and so on.

The aim of this PR is refactoring all this additional logic in a new class: NetworkManager, which contains

  • networks: a list of all the available Network;
  • currentNetwork: the current selected Network.
  • All the logic to switch network when an operation failed, safe fetch and so on.

In this way we can very easily add new Network classes: for example with #427 we found that most network operations can be done by using RPC Nodes. So in a future PR we can add a new Network realization RPCNetwork, and add to NetworkManager::networks the corresponding objects, like

networks.push(new RPCNetwork('rpc.duddino.com'))

And users could use the new network without any additional changes.


Testing

Test that syncing/sending txs and everything else is working as expected

@panleone panleone added the Refactor A PR or suggestion for rewriting existing code. label Oct 18, 2024
@panleone panleone self-assigned this Oct 18, 2024
Copy link

netlify bot commented Oct 18, 2024

Deploy Preview for cheery-moxie-4f1121 ready!

Name Link
🔨 Latest commit 52b472b
🔍 Latest deploy log https://app.netlify.com/sites/cheery-moxie-4f1121/deploys/67129211556d700008ad2ed8
😎 Deploy Preview https://deploy-preview-431--cheery-moxie-4f1121.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@Duddino Duddino left a comment

Choose a reason for hiding this comment

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

I haven't started the review yet, but can you move everything network in an aptly named network/ folder?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Refactor A PR or suggestion for rewriting existing code.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

2 participants