feat(core): switching networks #187
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.
Description
This ensures that the consuming app is properly updated whenever the active network is changed. The Algod client used internally by wallets is set to a property in the
WalletManager
class, but in the consuming app it needs to be reactive.So the framework adapters now handle the creation of new
Algodv2
clients on mount and when the network is changed. It is stored it in a reactive variable and synced to the manager'salgodClient
property.A new
setActiveNetwork
function is exported fromuseWallet
which updates the store then creates a new Algod client with the new network's config, setting it to the reactive variable andmanager.algodClient
simultaneously. Both variables are referentially equal.(When using the core library only, the process of changing active networks remains the same.)
In the Vue adapter, the reactive
algodClient
is a computedref
object and must now be accessed by itsvalue
property, e.g.,Disconnect all wallets on network change
When the network changes all connected wallets are disconnected. This is a new feature. Most wallets require the user to reconnect before transactions for a different network can be signed.
Refactors React and SolidJS adapters
To keep these two framework adapters as simple as possible, all of the source code is combined into a single file.
Other changes