Skip to content

Implement Soroban read-only contract calls: getEscrowInfo, getBalance, getProgramInfo, getRemainingBalance #44

Description

@Jagadeeshftw

📌 Description

In internal/soroban/escrow.go the read-only methods GetEscrowInfo/getEscrowInfoRPC and GetBalance/getBalanceRPC are stubs that log a warning and return without real data; the same is true for GetProgramInfo/getProgramInfoRPC and GetRemainingBalance/getRemainingBalanceRPC in internal/soroban/program.go. They never decode the contract return value from a simulation. Any payout flow that needs to read on-chain escrow state has nothing to call.

💡 Why it matters: Without working read paths, the backend cannot verify on-chain escrow/program balances before or after writes, undermining the payout lifecycle.

🧩 Requirements and context

  • Implement the read paths using SimulateTransaction against the escrow/program contracts and decode the returned ScVal via the helpers in internal/soroban/xdr_helpers.go.
  • Return typed Go structs for escrow info, balance, program info, and remaining balance.
  • Propagate context and the existing 30s HTTP timeout; return clear errors instead of logging-and-returning-empty.
  • Add unit tests decoding representative simulation responses (mock RPC).
  • Keep write paths (Init/Lock/Release/Refund/Payout) unchanged.

Non-functional requirements

  • Must be secure, tested, and documented.
  • Should be efficient and easy to review.

🛠️ Suggested execution

1. Fork the repo and create a branch

git checkout -b feat/soroban-readonly-calls

2. Implement changes

  • Write/modify the relevant source: internal/soroban/escrow.go, internal/soroban/program.go, possibly internal/soroban/rpc.go
  • Write comprehensive tests: internal/soroban/escrow_test.go, internal/soroban/program_test.go
  • Add documentation: GoDoc on the new return types
  • Include GoDoc comments explaining ScVal decoding
  • Validate security assumptions: treat simulation results as untrusted; validate types before decoding

3. Test and commit

  • Run tests:
go test ./internal/soroban/...
  • Cover edge cases: empty result, unexpected ScVal type, RPC error
  • Include test output and security notes in the PR description.

Example commit message

feat(soroban): implement read-only escrow/program contract calls

✅ Acceptance criteria

  • All four read methods return decoded data, not stub warnings
  • Context and timeout propagated; errors surfaced
  • ScVal decoding covered by unit tests with mock RPC
  • Write paths unchanged

🔒 Security notes

Simulation output is attacker-influenceable on a public RPC; validate every decoded field and never trust length/type without checks.

📋 Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial CampaignGrantFox official campaign issuebackendBackend / API workenhancementNew feature or requestsmart-contractSoroban/Rust smart contract work
No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions