Struct pallet_chainlink_feed::pallet::Pallet [−][src]
pub struct Pallet<T>(_);
Expand description
The pallet implementing the on-chain logic.
Implementations
pub fn create_feed(
origin: OriginFor<T>,
payment: BalanceOf<T>,
timeout: T::BlockNumber,
submission_value_bounds: (T::Value, T::Value),
min_submissions: u32,
decimals: u8,
description: Vec<u8>,
restart_delay: u32,
oracles: Vec<(T::AccountId, T::AccountId)>,
pruning_window: Option<u32>,
max_debt: Option<BalanceOf<T>>
) -> DispatchResultWithPostInfo
pub fn create_feed(
origin: OriginFor<T>,
payment: BalanceOf<T>,
timeout: T::BlockNumber,
submission_value_bounds: (T::Value, T::Value),
min_submissions: u32,
decimals: u8,
description: Vec<u8>,
restart_delay: u32,
oracles: Vec<(T::AccountId, T::AccountId)>,
pruning_window: Option<u32>,
max_debt: Option<BalanceOf<T>>
) -> DispatchResultWithPostInfo
Create a new oracle feed with the given config values.
This will issue the next available feed ID (FeedCounter
) and
assign it to the new feed.
Limited to feed creator accounts that where granted permission by
the pallet admin to create feeds via set_feed_creator
.
Parameters:
payment
: The amount of funds an oracle should received per valid round submission.timeout
: The timeout in blocks, after which a started round is timed out. If a round started in blockn
and the feed’stimeout
is10
, then the round is timed out ifn + 10 < current_block
.submission_value_bounds
: The value bounds of oracle submissions that are considered valid.min_submissions
: Determines the lower end of the feed’ssubmission_count_bounds
where the maximum number of submissions a round records is the number of configured oracles and the lower end is the minimum amount of submissions a round needs to update an answer viaAnswerUpdated
event.decimals
: Metadata that represents the number of decimals with which the feed is configured.description
: A user friendly name or ticker of this feed. Limited in length byStringLimit
.restart_delay
: The number of rounds that must elapse before a new round can be initiated by the same oracle again. Therefore this must be lower than the number of provided oracles.oracles
: A list of the oracle accounts together with their admin account (oracle
,admin
) that will be registered as oracles for the feed. If the oracle account is already tracked (for another feed for example), then the provided admin must match the already tracked oracle’s admin (seeOracles
). At least one (oracle
,admin
) pair is required.pruning_window
: This specifies the number of rounds to keep in storage for this feed. ANone
ensures that no past rounds are ever deleted from the chain’s storage. A value ofSome(n)
ensures thatn
rounds are kept in storage after the total number of rounds has exceededn
. This means that starting with then+1
round, the oldest round is purged from storage.max_debt
: WithSome(n)
the feed is allowed to accumulate a less or equal thann
amount of debt to the oracles. This means that oracles can submit values even if the feed’s fund is dry, and essentially receive an IOU that they can cash in once the feed is refunded.
Emits FeedCreated
event when successful.
pub fn transfer_ownership(
origin: OriginFor<T>,
feed_id: T::FeedId,
new_owner: T::AccountId
) -> DispatchResultWithPostInfo
pub fn transfer_ownership(
origin: OriginFor<T>,
feed_id: T::FeedId,
new_owner: T::AccountId
) -> DispatchResultWithPostInfo
Initiate the transfer of the feed to new_owner
.
Limited to the current owner of the feed.
This is a noop if the requested new_owner
is the sender itself
and the sender is already the owner.
Cancels a previously with transfer_ownership
initiated transfer of
ownership if it’s still pending.
This will fail if the pending_owner
already accepted the transfer
with accept_ownership
..
pub fn accept_ownership(
origin: OriginFor<T>,
feed_id: T::FeedId
) -> DispatchResultWithPostInfo
pub fn accept_ownership(
origin: OriginFor<T>,
feed_id: T::FeedId
) -> DispatchResultWithPostInfo
Accept the transfer of feed ownership.
pub fn set_pruning_window(
origin: OriginFor<T>,
feed_id: T::FeedId,
pruning_window: u32
) -> DispatchResultWithPostInfo
pub fn set_pruning_window(
origin: OriginFor<T>,
feed_id: T::FeedId,
pruning_window: u32
) -> DispatchResultWithPostInfo
Updates the pruning window of an existing feed
- Will prune rounds if the given window is smaller than the existing one.
Submit a new value to the given feed and round.
- Will start a new round if there is no round for the id, yet, and a round can be started (at this time by this oracle).
- Will update the round answer if minimum number of submissions has been reached.
- Records the rewards incurred by the oracle.
- Removes the details for the previous round if it was superseded.
Limited to the oracles of a feed.
Disable and add oracles for the given feed. Limited to the owner of a feed.
pub fn update_future_rounds(
origin: OriginFor<T>,
feed_id: T::FeedId,
payment: BalanceOf<T>,
submission_count_bounds: (u32, u32),
restart_delay: u32,
timeout: T::BlockNumber
) -> DispatchResultWithPostInfo
pub fn update_future_rounds(
origin: OriginFor<T>,
feed_id: T::FeedId,
payment: BalanceOf<T>,
submission_count_bounds: (u32, u32),
restart_delay: u32,
timeout: T::BlockNumber
) -> DispatchResultWithPostInfo
Update the configuration for future oracle rounds. Limited to the owner of a feed.
pub fn set_requester(
origin: OriginFor<T>,
feed_id: T::FeedId,
requester: T::AccountId,
delay: RoundId
) -> DispatchResultWithPostInfo
pub fn set_requester(
origin: OriginFor<T>,
feed_id: T::FeedId,
requester: T::AccountId,
delay: RoundId
) -> DispatchResultWithPostInfo
Set requester permissions for requester
.
Limited to the feed owner.
pub fn remove_requester(
origin: OriginFor<T>,
feed_id: T::FeedId,
requester: T::AccountId
) -> DispatchResultWithPostInfo
pub fn remove_requester(
origin: OriginFor<T>,
feed_id: T::FeedId,
requester: T::AccountId
) -> DispatchResultWithPostInfo
Remove requester permissions for requester
.
Limited to the feed owner.
pub fn request_new_round(
origin: OriginFor<T>,
feed_id: T::FeedId
) -> DispatchResultWithPostInfo
pub fn request_new_round(
origin: OriginFor<T>,
feed_id: T::FeedId
) -> DispatchResultWithPostInfo
Request the start of a new oracle round. Limited to accounts with “requester” permission.
pub fn withdraw_payment(
origin: OriginFor<T>,
oracle: T::AccountId,
recipient: T::AccountId,
amount: BalanceOf<T>
) -> DispatchResultWithPostInfo
pub fn withdraw_payment(
origin: OriginFor<T>,
oracle: T::AccountId,
recipient: T::AccountId,
amount: BalanceOf<T>
) -> DispatchResultWithPostInfo
Withdraw amount
payment of the given oracle to recipient
.
Limited to the oracle admin.
pub fn transfer_admin(
origin: OriginFor<T>,
oracle: T::AccountId,
new_admin: T::AccountId
) -> DispatchResultWithPostInfo
pub fn transfer_admin(
origin: OriginFor<T>,
oracle: T::AccountId,
new_admin: T::AccountId
) -> DispatchResultWithPostInfo
Initiate an admin transfer for the given oracle. Limited to the oracle admin account.
This is a noop if the requested new_admin
is the sender itself
and the sender is already the oracle admin.
Cancels a previously with transfer_admin
initiated transfer of
admin ownership for the given oracle, if the transfer is still
pending.
This will fail if the pending_admin
already accepted the transfer
with accept_admin
..
Complete an admin transfer for the given oracle. Limited to the pending oracle admin account.
pub fn withdraw_funds(
origin: OriginFor<T>,
recipient: T::AccountId,
amount: BalanceOf<T>
) -> DispatchResultWithPostInfo
pub fn withdraw_funds(
origin: OriginFor<T>,
recipient: T::AccountId,
amount: BalanceOf<T>
) -> DispatchResultWithPostInfo
Withdraw amount
funds to recipient
.
Limited to the pallet admin.
pub fn reduce_debt(
origin: OriginFor<T>,
feed_id: T::FeedId,
amount: BalanceOf<T>
) -> DispatchResultWithPostInfo
pub fn reduce_debt(
origin: OriginFor<T>,
feed_id: T::FeedId,
amount: BalanceOf<T>
) -> DispatchResultWithPostInfo
Reduce the amount of debt in the pallet by moving funds from the free balance to the reserved so oracles can be payed out. Limited to the pallet admin.
pub fn force_set_pallet_admin(
origin: OriginFor<T>,
new_pallet_admin: T::AccountId
) -> DispatchResult
pub fn force_set_pallet_admin(
origin: OriginFor<T>,
new_pallet_admin: T::AccountId
) -> DispatchResult
Sets the pallet admin account.
The dispatch origin for this call must be Root.
Unlike transfer_pallet_admin
, the new_pallet_admin
is not
required to accept the transfer, instead the PalletAdmin
is
forcibly set and the eventual pending transfer is aborted.
pub fn transfer_pallet_admin(
origin: OriginFor<T>,
new_pallet_admin: T::AccountId
) -> DispatchResultWithPostInfo
pub fn transfer_pallet_admin(
origin: OriginFor<T>,
new_pallet_admin: T::AccountId
) -> DispatchResultWithPostInfo
Initiate an admin transfer for the pallet. Limited to the pallet admin account.
This is a noop if the requested new_pallet_admin
is the sender
itself and the sender is already the pallet admin.
Cancels a previously with transfer_pallet_admin
initiated transfer
of the pallet admin ownership, if the transfer is still pending.
This will fail if the PendingPalletAdmin
already accepted the
transfer with accept_pallet_admin
.
Complete an admin transfer for the pallet. Limited to the pending pallet admin account.
pub fn set_feed_creator(
origin: OriginFor<T>,
new_creator: T::AccountId
) -> DispatchResultWithPostInfo
pub fn set_feed_creator(
origin: OriginFor<T>,
new_creator: T::AccountId
) -> DispatchResultWithPostInfo
Allow the given account to create oracle feeds. Limited to the pallet admin account.
pub fn remove_feed_creator(
origin: OriginFor<T>,
creator: T::AccountId
) -> DispatchResultWithPostInfo
pub fn remove_feed_creator(
origin: OriginFor<T>,
creator: T::AccountId
) -> DispatchResultWithPostInfo
Disallow the given account to create oracle feeds. Limited to the pallet admin account.
The account controlling the funds for this pallet.
A running counter used internally to determine the next feed id.
pub fn feed_config<KArg>(k: KArg) -> Option<FeedConfigOf<T>> where
KArg: EncodeLike<T::FeedId>,
pub fn feed_config<KArg>(k: KArg) -> Option<FeedConfigOf<T>> where
KArg: EncodeLike<T::FeedId>,
A running counter used internally to determine the next feed id.
pub fn round<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Option<RoundOf<T>> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<RoundId>,
pub fn round<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Option<RoundOf<T>> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<RoundId>,
User-facing round data.
pub fn round_details<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> Option<RoundDetailsOf<T>> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<RoundId>,
pub fn round_details<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> Option<RoundDetailsOf<T>> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<RoundId>,
Operator-facing round data.
Global oracle meta data including admin and withdrawable funds.
pub fn oracle_status<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> Option<OracleStatusOf<T>> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<T::AccountId>,
pub fn oracle_status<KArg1, KArg2>(
k1: KArg1,
k2: KArg2
) -> Option<OracleStatusOf<T>> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<T::AccountId>,
Feed local oracle status data.
pub fn requester<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Option<Requester> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<T::AccountId>,
pub fn requester<KArg1, KArg2>(k1: KArg1, k2: KArg2) -> Option<Requester> where
KArg1: EncodeLike<T::FeedId>,
KArg2: EncodeLike<T::AccountId>,
Per-feed permissioning for starting new rounds.
Trait Implementations
Get the benchmarks available for this pallet. Generally there is one benchmark per extrinsic, so these are sometimes just called “extrinsics”. Read more
fn run_benchmark(
extrinsic: &[u8],
c: &[(BenchmarkParameter, u32)],
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32
) -> Result<Vec<BenchmarkResult>, BenchmarkError>
fn run_benchmark(
extrinsic: &[u8],
c: &[(BenchmarkParameter, u32)],
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32
) -> Result<Vec<BenchmarkResult>, BenchmarkError>
Run the benchmarks for this pallet.
Return a transient feed proxy object for interacting with the feed given by the id. Provides read-only access.
Return a transient feed proxy object for interacting with the feed given by the id. Provides read-write access.
type MutableFeed = Feed<T>
Returns the current storage version as supported by the pallet.
Returns the on-chain storage version of the pallet as stored in the storage.
The block is being finalized. Implement to have something happen.
This will be run when the block is being finalized (before on_finalize
).
Implement to have something happen using the remaining weight.
Will not fire if the remaining weight is 0.
Return the weight used, the hook will subtract it from current weight used
and pass the result to the next on_idle
hook if it exists. Read more
The block is being initialized. Implement to have something happen. Read more
Perform a module upgrade. Read more
Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more
Run integrity test. Read more
Run integrity test. Read more
This function is being called after every block import (when fully synced). Read more
The block is being finalized. Implement to have something happen. Read more
Something that should happen at genesis.
The block is being finalized.
Implement to have something happen in case there is leftover weight.
Check the passed remaining_weight
to make sure it is high enough to allow for
your pallet’s extra computation. Read more
The block is being initialized. Implement to have something happen. Read more
Perform a module upgrade. Read more
Name of the Rust module containing the pallet.
Version of the crate containing the pallet.
Extend the given vector by all of the pallets’ information that this type represents. Read more
All of the pallets’ information that this type represents.
Auto Trait Implementations
impl<T> RefUnwindSafe for Pallet<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Pallet<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
Compare self to key
and return true
if they are equal.
Causes self
to use its Binary
implementation when Debug
-formatted.
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
Causes self
to use its Octal
implementation when Debug
-formatted.
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
impl<T> PalletVersionToStorageVersionHelper for T where
T: GetStorageVersion + PalletInfoAccess,
impl<T> PalletVersionToStorageVersionHelper for T where
T: GetStorageVersion + PalletInfoAccess,
Pipes by value. This is generally the method you want to use. Read more
Borrows self
and passes that borrow into the pipe function. Read more
Mutably borrows self
and passes that borrow into the pipe function. Read more
Borrows self
, then passes self.borrow()
into the pipe function. Read more
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
Borrows self
, then passes self.as_ref()
into the pipe function.
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
Borrows self
, then passes self.deref()
into the pipe function.
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
Pipes a dereference into a function that cannot normally be called in suffix position. Read more
Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
Checks if self
is actually part of its subset T
(and can be converted to it).
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
The inclusion map: converts self
to the equivalent element of its superset.
Immutable access to the Borrow<B>
of a value. Read more
Mutable access to the BorrowMut<B>
of a value. Read more
Immutable access to the AsRef<R>
view of a value. Read more
Mutable access to the AsMut<R>
view of a value. Read more
Immutable access to the Deref::Target
of a value. Read more
Mutable access to the Deref::Target
of a value. Read more
Calls .tap()
only in debug builds, and is erased in release builds.
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_deref()
only in debug builds, and is erased in release
builds. Read more
Provides immutable access to the reference for inspection.
Calls tap_ref
in debug builds, and does nothing in release builds.
Provides mutable access to the reference for modification.
Calls tap_ref_mut
in debug builds, and does nothing in release builds.
Provides immutable access to the borrow for inspection. Read more
Calls tap_borrow
in debug builds, and does nothing in release builds.
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
Immutably dereferences self
for inspection.
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Calls tap_deref
in debug builds, and does nothing in release builds.
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences self
for modification.
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more