evm_oracle_state/
provider.rs1use std::{future::Future, pin::Pin};
2
3use alloy_primitives::{Address, B256, U256};
4
5use crate::{OracleError, RoundData};
6
7pub type ProviderFuture<'a, T> = Pin<Box<dyn Future<Output = Result<T, OracleError>> + Send + 'a>>;
9
10#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub struct OracleBlockRef {
13 pub number: u64,
15 pub hash: B256,
17}
18
19pub trait ChainlinkFeedProvider {
24 fn decimals(&self, proxy: Address) -> ProviderFuture<'_, u8>;
26
27 fn description(&self, proxy: Address) -> ProviderFuture<'_, String>;
29
30 fn version(&self, proxy: Address) -> ProviderFuture<'_, U256>;
32
33 fn latest_round_data(&self, proxy: Address) -> ProviderFuture<'_, RoundData>;
35
36 fn latest_round_data_at(
40 &self,
41 proxy: Address,
42 _block: Option<OracleBlockRef>,
43 ) -> ProviderFuture<'_, RoundData> {
44 self.latest_round_data(proxy)
45 }
46
47 fn aggregator(&self, proxy: Address) -> ProviderFuture<'_, Option<Address>>;
49
50 fn aggregator_at(
54 &self,
55 proxy: Address,
56 _block: Option<OracleBlockRef>,
57 ) -> ProviderFuture<'_, Option<Address>> {
58 self.aggregator(proxy)
59 }
60
61 fn aggregator_type_and_version(
67 &self,
68 _aggregator: Address,
69 ) -> ProviderFuture<'_, Option<String>> {
70 Box::pin(async { Ok(None) })
71 }
72
73 fn aggregator_type_and_version_at(
75 &self,
76 aggregator: Address,
77 _block: Option<OracleBlockRef>,
78 ) -> ProviderFuture<'_, Option<String>> {
79 self.aggregator_type_and_version(aggregator)
80 }
81
82 fn aggregator_code_hash(&self, _aggregator: Address) -> ProviderFuture<'_, Option<B256>> {
84 Box::pin(async { Ok(None) })
85 }
86
87 fn aggregator_code_hash_at(
89 &self,
90 aggregator: Address,
91 _block: Option<OracleBlockRef>,
92 ) -> ProviderFuture<'_, Option<B256>> {
93 self.aggregator_code_hash(aggregator)
94 }
95}