mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 01:21:01 +00:00
Make runtime api generate version and identifier information (#1226)
* Make `decl_runtime_apis!` implement `RuntimeApiInfo` for all runtime apis * Make the runtime side generate the info constants as well * Make `RuntimeApiInfo` implementation use the correct generics * Adds a test for the runtime api info stuff * Remove duplicated code by using block from `test-client` * Adds `compile_fail` tests for `api_version` * Adds documentation for `api_version` * Make `impl_runtime_apis!` generate `RUNTIME_API_VERSIONS` * Update documentation and tests for `RUNTIME_API_VERSIONS` * Implement `has_api` by using the `RuntimeApiInfo` * Make `impl_runtime_apis` check that trait identifiers are unique * Prefix all runtime api function with the corresponding trait So `execute_block` will be called `Core_execute_block`. This makes it possible to have traits implement a function with the same name. * Rebase master * Update after master rebase
This commit is contained in:
@@ -64,11 +64,23 @@ pub type Justification = Vec<u8>;
|
||||
|
||||
use traits::{Verify, Lazy};
|
||||
|
||||
/// A String that is a `&'static str` on `no_std` and a `String` on `std`.
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub type RuntimeString = &'static str;
|
||||
/// A String that is a `&'static str` on `no_std` and a `Cow<'static, str>` on `std`.
|
||||
#[cfg(feature = "std")]
|
||||
pub type RuntimeString = ::std::borrow::Cow<'static, str>;
|
||||
#[cfg(not(feature = "std"))]
|
||||
pub type RuntimeString = &'static str;
|
||||
|
||||
/// Create a const [RuntimeString].
|
||||
#[cfg(feature = "std")]
|
||||
#[macro_export]
|
||||
macro_rules! create_runtime_str {
|
||||
( $y:expr ) => {{ ::std::borrow::Cow::Borrowed($y) }}
|
||||
}
|
||||
#[cfg(not(feature = "std"))]
|
||||
#[macro_export]
|
||||
macro_rules! create_runtime_str {
|
||||
( $y:expr ) => {{ $y }}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub use serde::{Serialize, de::DeserializeOwned};
|
||||
|
||||
@@ -639,3 +639,11 @@ pub trait GetNodeBlockType {
|
||||
/// The `NodeBlock` type.
|
||||
type NodeBlock: self::Block;
|
||||
}
|
||||
|
||||
/// Something that provides information about a runtime api.
|
||||
pub trait RuntimeApiInfo {
|
||||
/// The identifier of the runtime api.
|
||||
const ID: [u8; 8];
|
||||
/// The version of the runtime api.
|
||||
const VERSION: u32;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user