-
Notifications
You must be signed in to change notification settings - Fork 137
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 is a global singleton #112
Comments
agreed. I have a test app that talks to different networks, some test, some live. Kind of a pain to have to worry about this. |
Taking some notes here for someone in the future to figure out what it'd take to do this. Places that check for the current network:
It should be easy enough for |
What's the status of this? Can I take this to work on? |
@Akuukis > What's the status of this? Can I take this to work on? Go for it! what do you have in mind? I think it would be a good idea to follow @morleyzhi's suggestion to do it in a way such as we can introduce a warning and then do the deprecation later. |
@abuiles, yes, with deprecation warning! There's another issue to discuss - how to handle network passphrase within
The problem with 1. is that it's not intuitive. For me, I think of Transaction as either coming from specific network, or crafted for specific network (because state of ledger matters, especially sequence number). And this design opens a absurd possibility to add signatures targeted for different networks. Furthermore, given 1. option in order to check list of signatures at my favorite helper I would need to pass wrapped-object The problem with 2. option is that So I'd go with 2. or 3. option. What's your thoughts? |
Nice to see that this is finally tackled :) Just my two cents: I think 3 unfortunately also is the least elegant approach, since it's almost impossible to reason about the code if it will run reliably or not if a pretty-much mandatory parameter is only set lazily via a setter. I do agree with the shortcomings of 1 and 2, though, too. But maybe the shortcomings of 2 are in practice the smallest burden as a The role of the |
Please see PR #207 for 2nd option. |
What's your thoughts on which option to proceed? |
I think the second option makes the most sense, looks good! |
FWIW in the Go SDK we also set the network during construction of a |
@Akuukis thanks! I'll review your PR tomorrow. |
@andywer this has been released in 1.1.0, we still need to update the sdk to use this version. |
Awesome stuff! This change will save so many developers from a recurring headache 😄🎉 |
@andywer sweet! could you give it a try? |
@abuiles Sorry, didn't find the time yet, but I will try to give it a short in the next few days! |
... and that's a quite big no-no, especially in JS land 😕
Consider this use case (we have a similar situation as we speak):
There is a package X using
stellar-sdk
and a package Y usingstellar-sdk
as well, but a slightly different version.If Y is a dependency of X or if X and Y are both being used in another package Z then we will end up with a nasty situation. The
Network
singleton that X imports fromstellar-sdk
/stellar-base
won't be the same instance that Y has, since they each depend on a different version (two differentstellar-base
in thenode_modules/
tree).Thus you can run
Network.useTestNetwork()
in X and still get aNo network selected.
error in Y. Same happens whennpm link
-ing packages during development, even if all packages require the same version.Proposal
Is there actually a need to have this stateful
Network
singleton? I would favor a solution based on passing the pubnet/testnet switch to theServer
constructor, since horizon servers won't suddenly change the network they are running on.Sorry for the wall of text 😉
The text was updated successfully, but these errors were encountered: