fix!: Switch to a network and client param solution #1748
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous solution had some confusing aspects. E.g when using devnet (which is only a URL, and otherwise not different from testnet)
Now, all functions that need fetch, can take a
network
param to specify which URL+fetchFn to use. All of these function ALSO take the newclient
param. But it's okay to supplynetwork
,client
, both or neither. Stacks.js will default tomainnet
or infer which network to use. This way we can easily override URL for APIs, but also create manageablenetwork
objects that can be passed around everywhere (what people do currently in Stacks.js code).Want to create your custom network?
Override things if you want for
client
stuff.This also makes it easier to combine network and API/RPC clients.
This way we always know if a function does something with it's fetching/
client
-- e.g.