From eb9895c42ed94e48d6b39da8ba71c100003ab6a6 Mon Sep 17 00:00:00 2001 From: Busari Date: Sat, 30 May 2026 19:46:01 +0100 Subject: [PATCH] feat: add get_milestone view function --- campaign/src/get_milestone.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 campaign/src/get_milestone.rs diff --git a/campaign/src/get_milestone.rs b/campaign/src/get_milestone.rs new file mode 100644 index 0000000..8c2d14c --- /dev/null +++ b/campaign/src/get_milestone.rs @@ -0,0 +1,14 @@ +use soroban_sdk::{contract, contractimpl, Env}; +use crate::types::{Error, MilestoneData}; +use crate::storage::get_milestone; + +/// Issue #199 – `get_milestone` view function +/// +/// Returns the full `MilestoneData` for the milestone at `index`. +/// Panics with `Error::MilestoneNotFound` if the index is out of range. +/// No authentication required. +pub fn get_milestone_view(env: &Env, index: u32) -> MilestoneData { + get_milestone(env, index).unwrap_or_else(|| { + soroban_sdk::panic_with_error!(env, Error::MilestoneNotFound) + }) +}