π 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
π 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
π Description
settlement(env, id)returns the entireSettlementstruct (id, anchor, asset, amount, fee, status, opened_at) even when a caller β such as an off-chain keeper deciding whether to callexecute_settlementorcancel_expired_settlementβ only needs thestatusfield.is_settlement_expiredalready demonstrates the value of a narrow, purpose-built read over fetching and inspecting the full record.π§© Requirements and context
settlement_status(env, id) -> Result<SettlementStatus, Error>returningError::SettlementNotFoundfor a missing id, matchingsettlement's error behavior.storage::get_settlementand project out just thestatusfield (a full fetch is unavoidable given the current storage layout, but this still narrows the client-facing return type and payload).π οΈ Suggested execution
src/lib.rs, nearsettlement/settlement_exists.src/test.rscoverage for an existing settlement in each of the fourSettlementStatusvariants and for a missing id.β Acceptance criteria
settlement_status(id)returns the correctSettlementStatusfor an existing settlement.Error::SettlementNotFoundfor a nonexistent id, matchingsettlement's error.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