Skip to content
Snippets Groups Projects
Unverified Commit 9cbcb529 authored by wangjj9219's avatar wangjj9219 Committed by GitHub
Browse files

impl trait DataProviderExtended (#153)

parent 701929e7
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,7 @@ use sp_std::{fmt, marker, prelude::*, result, vec}; ...@@ -26,7 +26,7 @@ use sp_std::{fmt, marker, prelude::*, result, vec};
// would cause compiling error in `decl_module!` and `construct_runtime!` // would cause compiling error in `decl_module!` and `construct_runtime!`
// #3295 https://github.com/paritytech/substrate/issues/3295 // #3295 https://github.com/paritytech/substrate/issues/3295
use frame_system::{self as system, ensure_signed}; use frame_system::{self as system, ensure_signed};
pub use orml_traits::{CombineData, DataProvider, OnNewData, OnRedundantCall}; pub use orml_traits::{CombineData, DataProvider, DataProviderExtended, OnNewData, OnRedundantCall};
use sp_runtime::transaction_validity::{ use sp_runtime::transaction_validity::{
InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction, InvalidTransaction, TransactionValidity, TransactionValidityError, ValidTransaction,
}; };
...@@ -214,6 +214,12 @@ impl<T: Trait> DataProvider<T::OracleKey, T::OracleValue> for Module<T> { ...@@ -214,6 +214,12 @@ impl<T: Trait> DataProvider<T::OracleKey, T::OracleValue> for Module<T> {
} }
} }
impl<T: Trait> DataProviderExtended<T::OracleKey, T::OracleValue, T::AccountId> for Module<T> {
fn feed_value(who: T::AccountId, key: T::OracleKey, value: T::OracleValue) -> DispatchResult {
Self::_feed_values(who, vec![(key, value)])
}
}
impl<T: Trait> Module<T> { impl<T: Trait> Module<T> {
fn _feed_values(who: T::AccountId, values: Vec<(T::OracleKey, T::OracleValue)>) -> DispatchResult { fn _feed_values(who: T::AccountId, values: Vec<(T::OracleKey, T::OracleValue)>) -> DispatchResult {
ensure!(T::OperatorProvider::can_feed_data(&who), Error::<T>::NoPermission); ensure!(T::OperatorProvider::can_feed_data(&who), Error::<T>::NoPermission);
......
...@@ -304,6 +304,10 @@ pub trait DataProvider<Key, Value> { ...@@ -304,6 +304,10 @@ pub trait DataProvider<Key, Value> {
fn get(key: &Key) -> Option<Value>; fn get(key: &Key) -> Option<Value>;
} }
pub trait DataProviderExtended<Key, Value, AccountId>: DataProvider<Key, Value> {
fn feed_value(who: AccountId, key: Key, value: Value) -> DispatchResult;
}
pub trait PriceProvider<CurrencyId, Price> { pub trait PriceProvider<CurrencyId, Price> {
fn get_price(base: CurrencyId, quote: CurrencyId) -> Option<Price>; fn get_price(base: CurrencyId, quote: CurrencyId) -> Option<Price>;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment