Getline-Network / getline

Distributed P2P Lending System
https://getline.in
Apache License 2.0
9 stars 6 forks source link

[getline.ts] Detect network from context and automatically reload client when it changes #35

Open ritave opened 6 years ago

ritave commented 6 years ago

A single provider can change the network it's operating on. Currently the network version needs to be entered in the Client constructor, which is redundant and forces a single network over the whole lifetime of the application. This is simply not true - for example you can change the network in the Metamask interface without affecting currently open browser window. By detecting network from the context of Web3 instead of requiring hardcoded value in the constructor we can better support multiple networks in the future.

The solution is to poll the network once in a while and reload the state when the change happens. Other idea is to document the need to do this and ask the user to reconstruct the whole Getline.ts context? In that case provide a helper function?

q3k commented 6 years ago

I think this is out of scope for the current demo. However, this definitely needs to be addressed before release, as it will probably influence the getline.ts's API.

ritave commented 6 years ago

@q3k we could simplify it by getting the network once during construction. without polling afterwards. Manual input of network id is useless when we're providing a web3 provider anyways in the same constructor