Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
open-runtime-module-library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Noxim
open-runtime-module-library
Commits
9cbcb529
Unverified
Commit
9cbcb529
authored
4 years ago
by
wangjj9219
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
impl trait DataProviderExtended (#153)
parent
701929e7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
oracle/src/lib.rs
+7
-1
7 additions, 1 deletion
oracle/src/lib.rs
traits/src/lib.rs
+4
-0
4 additions, 0 deletions
traits/src/lib.rs
with
11 additions
and
1 deletion
oracle/src/lib.rs
+
7
−
1
View file @
9cbcb529
...
@@ -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
);
...
...
This diff is collapsed.
Click to expand it.
traits/src/lib.rs
+
4
−
0
View file @
9cbcb529
...
@@ -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
>
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment