Skip to content
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(network): enable runtime connection to custom Algorand nodes #339

Merged
merged 26 commits into from
Jan 22, 2025

Conversation

drichar
Copy link
Collaborator

@drichar drichar commented Jan 17, 2025

Description

This PR adds the ability to connect to custom Algorand nodes at runtime through the new updateAlgodConfig method. Users can now dynamically modify network configurations to connect to their own nodes after initialization, with their customizations persisting between sessions. As part of this change, network functionality has been refactored into a dedicated useNetwork hook for better organization and maintainability.

Details

  • Add updateAlgodConfig and resetNetworkConfig methods to modify network configurations at runtime
  • Enable dynamic switching between different Algorand nodes
  • Preserve existing network configuration when partially updating
  • Automatically update active algod client when modifying the active network
  • Persist user network customizations between sessions while preserving developer defaults
  • Split network functionality into dedicated useNetwork hook for better organization
  • Add comprehensive test coverage for network configuration updates
  • Update all framework adapters (React, Vue, Solid) for consistency

Add `updateNetworkAlgod` method to `WalletManager` to allow updating algod
configuration for any network at runtime. This enables users to connect to
their own Algorand nodes by modifying the network configuration after
initialization.

- Add `updateNetworkAlgod` method to `WalletManager` class
- Add comprehensive test suite for the new method
- Handle validation of updated configurations
- Automatically update active algod client when modifying active network
- Preserve existing configuration when partially updating
- Move network functionality (`activeNetwork`, `algodClient`, `setActiveNetwork`, etc.)
  to `useNetwork`
- Reorganize exports to match logical grouping (Provider, Network, Wallet)
- Update tests to reflect new hook separation
- Add comprehensive test coverage for `useNetwork` hook
- Remove network-related properties from `useWallet` tests
- Export additional network types from `use-wallet` package

BREAKING CHANGE: Network-related properties and methods have been moved from
`useWallet` to the new `useNetwork` hook.
- Move network functionality (`activeNetwork`, `algodClient`, `setActiveNetwork`) to
  `useNetwork`
- Reorganize exports to match logical grouping (Provider, Network, Wallet)
- Update tests to reflect new function separation
- Add comprehensive test coverage for `useNetwork`
- Remove network-related properties from `useWallet` tests
- Export additional network types from `use-wallet` package
- Improve test organization and setup

BREAKING CHANGE: Network-related properties and methods have been moved from
`useWallet` to the new `useNetwork` function.
Move network-related functionality from `useWallet` to `useNetwork` composable to
improve code organization and separation of concerns. Update tests to reflect
the new structure.

- Move `algodClient` and `setAlgodClient` to `useNetwork`
- Move `setActiveNetwork` and `activeNetwork` to `useNetwork`
- Split network-related tests into `useNetwork.test.ts`
- Update `useWallet` tests to remove network assertions
- Improve test setup with better mock organization

BREAKING CHANGE: Network-related properties (`algodClient`, `setAlgodClient`,
`activeNetwork`, `setActiveNetwork`) have been moved from `useWallet` to a new
`useNetwork` composable.
Remove `name` property from `NetworkConfig` in tests to match updated type
definition. This aligns test fixtures with the core `NetworkConfig` type that
no longer includes the optional name field.
Add `updateNetworkAlgod` function to Vue adapter and test coverage for both Vue
and Solid adapters. This completes the network configuration functionality
across all framework adapters, ensuring consistent behavior for runtime algod
config updates.
Split network-related functionality from `useWallet` into separate `useNetwork` hook
across all framework examples.

- Move `algodClient`, `activeNetwork`, and `setActiveNetwork` to `useNetwork`
- Update Next.js example to use split hooks
- Update Nuxt example to use split hooks
- Update React example to use split hooks
- Update Solid example to use split hooks
- Update Vue example to use split hooks
When updating network configuration through `updateNetworkAlgod`, ensure the
`algodClient` is also updated in the store if the modified network is currently
active.
Add `activeNetworkConfig` to `useNetwork` across React, Vue, and Solid implementations:
- Add `activeNetworkConfig` property to `WalletManager` in core library
- Expose current network configuration through `useNetwork` hook
- Add tests to verify network config updates correctly
- Ensure reactivity when switching networks or updating config at runtime
@drichar drichar changed the title refactor(*): split network functionality into useNetwork hook feat(network): enable runtime connection to custom Algorand nodes Jan 20, 2025
Add support for persisting user-modified network configurations while preserving
developer-provided defaults. This enables users to customize network settings
that persist between sessions without affecting the base configuration.

- Add `customNetworkConfigs` to persisted state
- Store base network config separately from runtime config
- Compare against base config to identify user customizations
- Update tests to verify persistence behavior
@drichar drichar force-pushed the feat/runtime-algod-config-update branch from b120f37 to a5dccfa Compare January 20, 2025 23:56
Add `resetNetworkConfig` method to `WalletManager` and expose it through framework adapters. This allows resetting a network's configuration to its default state, removing any customizations.

- Add `resetNetworkConfig` method to `WalletManager` class
- Add tests for `WalletManager` `resetNetworkConfig` functionality
- Expose `resetNetworkConfig` through React, Vue, and Solid adapters
- Add comprehensive tests for each adapter implementation
Update the `algodClient` state when updating network configuration to ensure UI
reflects the current network state. This fixes an issue where the UI would not
update after resetting network configuration.
Move `algodClient` and `setAlgodClient` from `useNetwork` to `useWallet` to
better align with their usage patterns. Update tests to handle shared context
between hooks and fix assertions around loading states.

- Remove `algodClient` and `setAlgodClient` from `useNetwork` return value
- Add `algodClient` and `setAlgodClient` to `useWallet` return value
- Update tests to use combined hooks when testing cross-hook interactions
- Fix integration test to properly handle loading states
Move `algodClient` from `useNetwork` to `useWallet` to maintain consistency with
React adapter changes. Update tests to reflect new hook structure.

- Remove `algodClient` from `useNetwork` return value
- Add `algodClient` to `useWallet` return value
- Update test components to access `algodClient` through `useWallet`
Move `algodClient` from `useNetwork` to `useWallet` composable to better align with
component responsibilities. Update tests to reflect new dependency structure and
improve injection mocking setup.

- Move `algodClient` computed property from `useNetwork` to `useWallet`
- Update `useNetwork` tests to get `algodClient` from `useWallet`
- Add `algodClient` injection handling in `useWallet` tests
- Move inject mock setup into `setupMocks` for consistent dependency initialization
Add network configuration forms to React and Vue examples with styling:
- Add config form component with server/port/token inputs
- Add form styling for light/dark modes
- Move network controls to separate component
- Update imports and component structure

The network configuration UI allows users to view and modify the
algod node configuration for each network.
Update Next, Nuxt, and Solid example apps to reflect the movement of `algodClient`
from `useNetwork` back to `useWallet`.
Move network configuration from `WalletManager` instance to store state to support
runtime network configuration updates and ensure reactivity across framework
adapters. This change enables the new feature that lets users modify network
settings at runtime while ensuring those updates are properly tracked in the
reactive store.

- Adds `networkConfig` to store state
- Updates all references to use `store.state.networkConfig`
- Removes `networks` prop from wallet constructors
- Simplifies `algodClient` creation by passing config directly
Update React and Vue adapters and examples to use `networkConfig` from store state
instead of the removed `networks` property. This change follows up on moving network
configuration to the reactive store.

- Update `useNetwork` hook/composable to return `networkConfig` instead of `networks`
- Update `NetworkControls` components in React/Vue examples
- Fix affected tests in both adapter packages
Update Solid adapter to use reactive store for network configuration and add
`NetworkControls` component to demonstrate runtime network configuration. This
change improves reactivity in the Solid example project to match React and Vue
implementations.

- Add `NetworkControls` component with config form UI
- Update `useNetwork` function to use store state for better reactivity
- Remove network controls from `Connect` component
- Add styles for network configuration UI
- Update tests to reflect new network config handling
Make logging more consistent across framework adapters when creating new
`algodClient` instances. This change:

- Standardize log message format across React/Vue/Solid
- Add missing log statements for client creation
- Add clarifying comments about `algodClient` updates
Rename constant to better reflect its purpose as configuration data rather than
network instances.
Rename method to better reflect its purpose of updating algod configuration
rather than the entire network.

- Rename `updateNetworkAlgod` to `updateAlgodConfig` in `WalletManager`
- Update method name in React/Vue/Solid adapters
- Update all test files to use new method name
- Update example projects to use renamed method
@drichar drichar merged commit 6d6494e into v4 Jan 22, 2025
1 check passed
@drichar drichar deleted the feat/runtime-algod-config-update branch January 22, 2025 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant