Description
The SDK is initialized with hard-coded Horizon and Soroban RPC URLs, making it cumbersome to switch between mainnet, testnet, and futurenet during development or integration testing without re-instantiating the entire client. A first-class environment switcher would provide built-in network presets, validate that the active network passphrase matches the RPC endpoint's reported passphrase, and allow runtime network swapping while in-flight requests finish cleanly.
Technical Context
Extends src/config.ts with a NetworkEnvironment enum (MAINNET | TESTNET | FUTURENET | CUSTOM) and a NetworkPreset interface mapping each value to { horizonUrl: string; rpcUrl: string; networkPassphrase: string }. The StellarSplitClient in src/client.ts gains a switchNetwork(env: NetworkEnvironment | NetworkPreset): Promise<void> method. Passphrase cross-check uses SorobanRpc.Server.getNetwork() from @stellar/stellar-sdk.
Acceptance Criteria
Description
The SDK is initialized with hard-coded Horizon and Soroban RPC URLs, making it cumbersome to switch between mainnet, testnet, and futurenet during development or integration testing without re-instantiating the entire client. A first-class environment switcher would provide built-in network presets, validate that the active network passphrase matches the RPC endpoint's reported passphrase, and allow runtime network swapping while in-flight requests finish cleanly.
Technical Context
Extends
src/config.tswith aNetworkEnvironmentenum (MAINNET | TESTNET | FUTURENET | CUSTOM) and aNetworkPresetinterface mapping each value to{ horizonUrl: string; rpcUrl: string; networkPassphrase: string }. TheStellarSplitClientinsrc/client.tsgains aswitchNetwork(env: NetworkEnvironment | NetworkPreset): Promise<void>method. Passphrase cross-check usesSorobanRpc.Server.getNetwork()from@stellar/stellar-sdk.Acceptance Criteria
switchNetwork(NetworkEnvironment.TESTNET)reconfigures internal Horizon and RPC URL references and validates the passphrase against the live RPC endpoint before accepting the switchNetworkEnvironment.CUSTOMwithout a fullNetworkPresetobject produces a TypeScript compile-time error via function overload typingswitchNetworkresolves use the new configurationNetworkMismatchError(withexpectedandactualpassphrase fields) is thrown when the live RPC passphrase does not match the preset