safe_oracle/reflector_client.rs
1use crate::{Asset, PriceData};
2use soroban_sdk::{contractclient, Env, Vec};
3
4/// Reflector oracle interface (SEP-40 compliant subset that `safe_oracle` consumes).
5///
6/// Defines the public surface of the Reflector contract. The
7/// `#[contractclient]` macro auto-generates a `ReflectorClient` struct from
8/// this trait — clients are instantiated as `ReflectorClient::new(env, address)`
9/// and used as `client.lastprice(&asset)`.
10///
11/// In production this binds to the real Reflector mainnet address; in tests it
12/// binds to the `MockReflector` address. The integration code is identical
13/// across both — only the runtime address changes.
14///
15/// Method signatures must match `mock_reflector` (and the real Reflector
16/// contract) exactly:
17/// - `mock_reflector::lastprice(env: Env, asset: Asset) -> Option<PriceData>`
18/// - `mock_reflector::lastprices(env: Env, asset: Asset, records: u32) -> Option<Vec<PriceData>>`
19/// - `mock_reflector::decimals(env: Env) -> u32`
20/// - `mock_reflector::resolution(env: Env) -> u32`
21// The trait exists solely so `#[contractclient]` can synthesize the client
22// struct; nothing calls it directly (the macro re-emits the signatures).
23#[allow(dead_code)]
24#[contractclient(name = "ReflectorClient")]
25pub trait Reflector {
26 fn lastprice(env: Env, asset: Asset) -> Option<PriceData>;
27 fn lastprices(env: Env, asset: Asset, records: u32) -> Option<Vec<PriceData>>;
28 fn decimals(env: Env) -> u32;
29 fn resolution(env: Env) -> u32;
30}