Skip to content

Add a shared Soroban RPC server accessor to TrustFlowClient #134

Description

@meshackyaro

Description

This issue aims to address the implementation of Shared Soroban RPC Server Accessor on TrustFlowClient.

The core objective is to: Add a client.getSorobanServer() method to TrustFlowClient (mirroring its existing getServer() for Horizon) so that src/contract/invoke.ts, src/contract/read.ts, and src/contract/simulate.ts share one RPC server instance per client instead of each independently calling new SorobanRpc.Server(SOROBAN_RPC_URLS[client.network]). Today all three files construct their own throwaway RPC server client on every single call, with no caching or connection reuse, and any future cross-cutting change (timeouts, auth headers, retry wiring) would need to be applied in three separate places.

By completing this feature, we will ensure that the TrustFlow protocol maintains its high standards for security, usability, and decentralized logic. This issue requires careful attention to the SDK Wrapper architecture and adherence to the existing project conventions.

Component

SDK

Difficulty

🔴 Hard

Tasks

  • Review existing Typescript abstract classes (TrustFlowClient in src/client.ts, which already exposes getServer() for Horizon.Server)
  • Implement SDK method for: a getSorobanServer() accessor on TrustFlowClient that lazily constructs and caches a SorobanRpc.Server (once the SorobanRpc import is fixed per a companion issue)
  • Update src/contract/invoke.ts, read.ts and simulate.ts to use the new client.getSorobanServer() instead of constructing their own instances
  • Update typedoc comments for the new method
  • Write Jest tests validating the accessor returns a consistent, cached instance
  • Run npm run build to verify standard bundling

Acceptance Criteria

  • Feature accurately implements the objective: a client.getSorobanServer() method exists and is reused by contract/invoke.ts, read.ts and simulate.ts
  • contract/invoke.ts, read.ts and simulate.ts no longer each construct their own SorobanRpc.Server instances
  • Any PR that introduces TypeScript errors is automatically blocked
  • Code is properly reviewed and approved by codeowners

Estimated Time

2-3 days

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions