-
-
Notifications
You must be signed in to change notification settings - Fork 35
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(core): switching networks #187
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This also refactors the `useWallet` hook so it directly accesses `WalletContext` (in place of the `useWalletManager` hook). Both modules are now in a single file - src/index.tsx
55c0c40
to
155e2f8
Compare
19a4a37
to
56f7528
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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