Skip to content

refactor(network): add network client for standardized requests - #158

Merged
El-swaggerito merged 1 commit into
Axionvera:mainfrom
Lakes41:lakes1
Jul 21, 2026
Merged

refactor(network): add network client for standardized requests#158
El-swaggerito merged 1 commit into
Axionvera:mainfrom
Lakes41:lakes1

Conversation

@Lakes41

@Lakes41 Lakes41 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements a typed network client abstraction for Horizon and future Soroban RPC usage, ensuring consistent timeout handling, response parsing, and SDK error conversion for all network operations.

Changes

  • Added NetworkClient class (src/network/index.ts#L81-L187): Typed HTTP client with get and post methods, built on top of existing fetchWithTimeout with consistent error handling and JSON parsing
  • Added executeHorizonOperation helper (src/network/index.ts#L192-L213): Wraps Horizon server operations with timeout and consistent error handling
  • Added executeSorobanOperation helper (src/network/index.ts#L218-L231): Wraps Soroban RPC operations with timeout and consistent error handling
  • Updated fundTestnetAccount (src/wallet/index.ts#L198-L254): Refactored to use NetworkClient instead of direct fetchWithTimeout calls

Why

  • Reduces duplication of request logic across SDK modules
  • Ensures consistent timeout and error handling behavior
  • Provides a shared abstraction for future Soroban RPC usage
  • Converts network errors to consistent SDK error types

Testing

  • All existing tests pass (npm run test)
  • TypeScript compilation passes (npm run build)
  • No breaking changes to public SDK behavior

Closes #157

Replace manual fetchWithTimeout usage in fundTestnetAccount with the new NetworkClient. Update error handling to map generic HTTP errors to Friendbot-specific error codes. Add executeHorizonOperation and executeSorobanOperation helpers for consistent operation wrapping.
@El-swaggerito
El-swaggerito merged commit 4857783 into Axionvera:main Jul 21, 2026
1 check passed
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.

Implement SDK typed network client abstraction

2 participants