-
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
feat: deprecate Network, use explicit passphrase (2) #207
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Akuukis Looking good!
Besides the inline comments, could you do the following:
- Add a new section to the changelog called
### Unreleased
and document this change - Update the example here to use the new syntax https://github.com/Akuukis/js-stellar-base/blob/explicit-network-2/src/transaction.js#L106
We also need to update the docs to make sure they reflect the new syntax, but it doesn't block this PR.
Thanks!
@abuiles Done! Anything else? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Akuukis looking good! One last change and I think we'll be good :). Let's avoid the breaking change for now and use a getter approach.
c648cc1
to
262aec1
Compare
@abuiles Review implemented, and all tests files reverted too (so no breaking changes noticed). Anything else? |
@Akuukis Thanks! I'll release this later today :) |
Hi guys, I just landed here after running a
The only reason I called that function was to make it happy, though:
|
@MisterTicot Hi! Hmm, I'm ready to take a look at it. Can you please share the link to your code or elaborate more on the context of error? Or, even better, extract a small snippet where it fails? |
I use stellar-sdk.js when You apdated It, stellar-sdk does not work with old version! |
@mkaliberda can you elaborate please? |
Recently updated to newer versions and now see warnings in our logs: This appears to be triggered by I don't understand the motivation behind this change by the way. The error message suggests that we now need to pass the network for every single transaction issued in our application? I am a little bit confused about the warning and the suggested solution (passing the network to tx constructor every time). Looking forward to some input on this @abuiles Thanks! |
Ideally you'd use an environment variable so you can easily change networks, including between testnet and mainnet deployments |
Okay. Thanks for the follow ups. So basically we can scrap What network is selected by default if we don't pass a passphrase to TransactonBuilder? It looks like the passphrase is being set to null if no opts.networkPassphrase is given: We currently don't work with Testnet. Do we need to specifically add Networks.PUBLIC (or env var, or some other way, etc.) to each transaction builder call or will it automatically select PUBLIC if no such opt is provided? Edit: Looks like it will simply throw an error down the road if the network is not set in the singleton. When support for the singleton is removed in the future the transactions will simply fail if no network is explicitly set in the opts. Is that intended? Wouldn't it be better to default the passPhrase to Networks.PUBLIC (or testnet) instead of |
Yes, I would specifically pass Networks.PUBLIC in places that expect a network passphrase. When you don't pass in a passphrase, it will fall back to the current Network.use*() setting: js-stellar-base/src/transaction.js Line 70 in 64785eb
Ostensibly when we remove Network.use*(), we'll throw an error wherever a network passphrase is expected but not supplied. |
we definitely don't want to default things to Networks.PUBLIC, if anything we'd default to TESTNET, but its better to have stuff like this just fail so it can be fixed properly instead of continuing to work in an undefined way |
Okay, thanks for the super fast replies! Figured it all out now. I'm definitely glad I subscribed to js-stellar-base so I can keep track of these changes more continuously. |
StellarSdk.Network.useTestNetwork() was deprecated by Networks.TESTNET constant, so this should be updated in order to be consistent with this update: stellar/js-stellar-base#207
Per deprecation warning message, which links to here: stellar/js-stellar-base#207
Per deprecation warning message, which links to here: stellar/js-stellar-base#207
For those using the sdk to connect with |
Deprecate global singleton for
Network
. The following classes and methods take an optional network passphrase, and issue a warning if it is not passed:Keypair.master
constructor for
Transaction
constructor for
TransactionBuilder
and methodTransactionBuilder.setNetworkPassphrase
The
Network
class will be removed on the2.0
release.Fixes #112.