Skip to content

Add settlement_status(id) as a cheaper read than the full Settlement recordΒ #112

Description

@Jagadeeshftw

πŸ“Œ Description

settlement(env, id) returns the entire Settlement struct (id, anchor, asset, amount, fee, status, opened_at) even when a caller β€” such as an off-chain keeper deciding whether to call execute_settlement or cancel_expired_settlement β€” only needs the status field. is_settlement_expired already demonstrates the value of a narrow, purpose-built read over fetching and inspecting the full record.

🧩 Requirements and context

  • Add settlement_status(env, id) -> Result<SettlementStatus, Error> returning Error::SettlementNotFound for a missing id, matching settlement's error behavior.
  • Implement it via storage::get_settlement and project out just the status field (a full fetch is unavoidable given the current storage layout, but this still narrows the client-facing return type and payload).
  • Document that this reduces cross-contract call payload size for keeper loops.

πŸ› οΈ Suggested execution

  • Add the entrypoint to src/lib.rs, near settlement/settlement_exists.
  • Add src/test.rs coverage for an existing settlement in each of the four SettlementStatus variants and for a missing id.
  • Mention the new view in the README settlement table.

βœ… Acceptance criteria

  • settlement_status(id) returns the correct SettlementStatus for an existing settlement.
  • It returns Error::SettlementNotFound for a nonexistent id, matching settlement's error.
  • The full settlement(id) entrypoint is unchanged.

πŸ”’ Security notes

A narrower read surface for keeper polling loops reduces the chance of a keeper accidentally branching on a stale or partially-read field from the larger struct, and keeps settlement-state checks auditable in one place.

πŸ“‹ Guidelines

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

Metadata

Metadata

Assignees

Labels

GrantFox OSSGrantFox open-source programMaybe RewardedGrantFox: potentially rewarded contributionOfficial Campaign | FWC26GrantFox official campaign issueperformancePerformance / gas / resource usesmart-contractSoroban/Rust smart contract work

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions