Trait polkadot_sdk_frame::runtime::apis::ApiExt
pub trait ApiExt<Block>where
Block: Block,{
// Required methods
fn execute_in_transaction<F, R>(&self, call: F) -> R
where F: FnOnce(&Self) -> TransactionOutcome<R>,
Self: Sized;
fn has_api<A>(
&self,
at_hash: <Block as Block>::Hash,
) -> Result<bool, ApiError>
where A: RuntimeApiInfo + ?Sized,
Self: Sized;
fn has_api_with<A, P>(
&self,
at_hash: <Block as Block>::Hash,
pred: P,
) -> Result<bool, ApiError>
where A: RuntimeApiInfo + ?Sized,
P: Fn(u32) -> bool,
Self: Sized;
fn api_version<A>(
&self,
at_hash: <Block as Block>::Hash,
) -> Result<Option<u32>, ApiError>
where A: RuntimeApiInfo + ?Sized,
Self: Sized;
fn record_proof(&mut self);
fn extract_proof(&mut self) -> Option<StorageProof>;
fn proof_recorder(
&self,
) -> Option<Recorder<<<Block as Block>::Header as Header>::Hashing>>;
fn into_storage_changes<B>(
&self,
backend: &B,
parent_hash: <Block as Block>::Hash,
) -> Result<StorageChanges<<<Block as Block>::Header as Header>::Hashing>, String>
where B: Backend<<<Block as Block>::Header as Header>::Hashing>,
Self: Sized;
fn set_call_context(&mut self, call_context: CallContext);
fn register_extension<E>(&mut self, extension: E)
where E: Extension;
}
Expand description
Extends the runtime api implementation with some common functionality.
Required Methods§
fn execute_in_transaction<F, R>(&self, call: F) -> R
fn execute_in_transaction<F, R>(&self, call: F) -> R
Execute the given closure inside a new transaction.
Depending on the outcome of the closure, the transaction is committed or rolled-back.
The internal result of the closure is returned afterwards.
fn has_api<A>(&self, at_hash: <Block as Block>::Hash) -> Result<bool, ApiError>
fn has_api<A>(&self, at_hash: <Block as Block>::Hash) -> Result<bool, ApiError>
Checks if the given api is implemented and versions match.
fn has_api_with<A, P>(
&self,
at_hash: <Block as Block>::Hash,
pred: P,
) -> Result<bool, ApiError>
fn has_api_with<A, P>( &self, at_hash: <Block as Block>::Hash, pred: P, ) -> Result<bool, ApiError>
Check if the given api is implemented and the version passes a predicate.
fn api_version<A>(
&self,
at_hash: <Block as Block>::Hash,
) -> Result<Option<u32>, ApiError>
fn api_version<A>( &self, at_hash: <Block as Block>::Hash, ) -> Result<Option<u32>, ApiError>
Returns the version of the given api.
fn record_proof(&mut self)
fn record_proof(&mut self)
Start recording all accessed trie nodes for generating proofs.
fn extract_proof(&mut self) -> Option<StorageProof>
fn extract_proof(&mut self) -> Option<StorageProof>
Extract the recorded proof.
This stops the proof recording.
If record_proof
was not called before, this will return None
.
fn proof_recorder(
&self,
) -> Option<Recorder<<<Block as Block>::Header as Header>::Hashing>>
fn proof_recorder( &self, ) -> Option<Recorder<<<Block as Block>::Header as Header>::Hashing>>
Returns the current active proof recorder.
fn into_storage_changes<B>(
&self,
backend: &B,
parent_hash: <Block as Block>::Hash,
) -> Result<StorageChanges<<<Block as Block>::Header as Header>::Hashing>, String>
fn into_storage_changes<B>( &self, backend: &B, parent_hash: <Block as Block>::Hash, ) -> Result<StorageChanges<<<Block as Block>::Header as Header>::Hashing>, String>
Convert the api object into the storage changes that were done while executing runtime api functions.
After executing this function, all collected changes are reset.
fn set_call_context(&mut self, call_context: CallContext)
fn set_call_context(&mut self, call_context: CallContext)
Set the CallContext
to be used by the runtime api calls done by this instance.
fn register_extension<E>(&mut self, extension: E)where
E: Extension,
fn register_extension<E>(&mut self, extension: E)where
E: Extension,
Register an [Extension
] that will be accessible while executing a runtime api call.