pub trait OracleApi<Block: BlockT, ProviderId, Key, Value>: Core<Block>where
ProviderId: Codec,
Key: Codec,
Value: Codec,{
// Provided methods
fn get_value(
&self,
__runtime_api_at_param__: <Block as BlockT>::Hash,
provider_id: ProviderId,
key: Key,
) -> Result<Option<Value>, ApiError> { ... }
fn get_all_values(
&self,
__runtime_api_at_param__: <Block as BlockT>::Hash,
provider_id: ProviderId,
) -> Result<Vec<(Key, Option<Value>)>, ApiError> { ... }
}Expand description
Runtime API for querying oracle data from the blockchain.
This trait provides methods to retrieve oracle data without requiring direct storage access. It’s designed to be called from external clients, RPC nodes, and other blockchain infrastructure components that need access to oracle information.
The API is generic over three type parameters:
ProviderId: Identifies the oracle provider or data sourceKey: The oracle key identifying the specific data feedValue: The oracle data value type
Provided Methods§
Sourcefn get_value(
&self,
__runtime_api_at_param__: <Block as BlockT>::Hash,
provider_id: ProviderId,
key: Key,
) -> Result<Option<Value>, ApiError>
fn get_value( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, provider_id: ProviderId, key: Key, ) -> Result<Option<Value>, ApiError>
Retrieves a specific oracle value for a given provider and key.
Returns the current oracle value if available, or None if no data exists
for the specified provider and key combination.
§Parameters
provider_id: The oracle provider identifierkey: The oracle key identifying the data feed
§Returns
Returns Some(value) if oracle data exists, None otherwise.
Sourcefn get_all_values(
&self,
__runtime_api_at_param__: <Block as BlockT>::Hash,
provider_id: ProviderId,
) -> Result<Vec<(Key, Option<Value>)>, ApiError>
fn get_all_values( &self, __runtime_api_at_param__: <Block as BlockT>::Hash, provider_id: ProviderId, ) -> Result<Vec<(Key, Option<Value>)>, ApiError>
Retrieves all oracle values for a specific provider.
Returns a vector of key-value pairs containing all available oracle data from the specified provider. Each pair contains the oracle key and its corresponding value (if available).
§Parameters
provider_id: The oracle provider identifier
§Returns
Returns a vector of (Key, Option<Value>) pairs representing all oracle
data available from the specified provider.