diff --git a/contracts/oracle-integration/src/lib.rs b/contracts/oracle-integration/src/lib.rs index ee9568c6..8dc2cf55 100644 --- a/contracts/oracle-integration/src/lib.rs +++ b/contracts/oracle-integration/src/lib.rs @@ -2,7 +2,7 @@ use soroban_sdk::{ contract, contracterror, contractevent, contractimpl, contracttype, Address, Bytes, BytesN, - Env, Vec, + Env, Symbol, Vec, }; #[contract] @@ -38,6 +38,29 @@ pub struct LatestPriceData { pub updated_ledger: u32, } +/// Snapshot of the configured oracle source addresses at read time. +/// Returns `None` from `source_config_snapshot` when the contract has not been initialized. +#[derive(Clone)] +#[contracttype] +pub struct OracleSourceSnapshot { + /// Whitelisted oracle addresses that may fulfill data requests. + pub sources: Vec
, + /// Number of configured sources (convenience field for clients). + pub source_count: u32, +} + +/// Summary of the update cadence and staleness policy in effect. +/// Deterministic: the same value is returned on every call. +#[derive(Clone)] +#[contracttype] +pub struct UpdatePolicySummary { + /// Number of ledgers after which a price is considered stale. + pub stale_threshold_ledgers: u32, + /// Describes when updates occur. `"on_request"` means data is fetched + /// per-request rather than on a fixed schedule. + pub cadence: Symbol, +} + #[derive(Clone)] #[contracttype] pub struct PriceFreshness { @@ -299,6 +322,43 @@ impl OracleIntegration { result } + // ───────── SOURCE CONFIG SNAPSHOT ───────── + + /// Returns a snapshot of the configured oracle source addresses. + /// + /// Returns `None` when the contract has not been initialized; callers should + /// treat a `None` result as "no sources configured" and not attempt data + /// requests until the contract is initialized. + pub fn source_config_snapshot(env: Env) -> Option