mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 10:31:04 +00:00
Refactor the runtime API to use traits. (#878)
* Add missing `As` imports. * Adds new API traits that will be used by the client and runtime * Switch consensus to new API's * Switches transaction-pool to new API's * Move runtime api stuff into its own crate * Adds `impl_apis!` macro for implementing the new API traits * Make `metadata` return directly a blob * Runtime replace `impl_stubs!` with `impl_apis!` * Switches to none feature based approach for declaring the different API traits * Fixes compilation error * Fixes errors * Make the `decl_apis!` trait usable from the outside * Make the `test-client` use the new API traits * Remove last `impl_stubs!` bits and move some of them into wasm executor for tests * A little bit more documentation
This commit is contained in:
@@ -33,12 +33,14 @@ macro_rules! impl_runtime_metadata {
|
||||
$( $rest:tt )*
|
||||
) => {
|
||||
impl $runtime {
|
||||
pub fn metadata() -> $crate::metadata::RuntimeMetadata {
|
||||
$crate::metadata::RuntimeMetadata {
|
||||
outer_event: Self::outer_event_metadata(),
|
||||
modules: __runtime_modules_to_metadata!($runtime;; $( $rest )*),
|
||||
outer_dispatch: Self::outer_dispatch_metadata(),
|
||||
}
|
||||
pub fn metadata() -> Vec<u8> {
|
||||
$crate::codec::Encode::encode(
|
||||
&$crate::metadata::RuntimeMetadata {
|
||||
outer_event: Self::outer_event_metadata(),
|
||||
modules: __runtime_modules_to_metadata!($runtime;; $( $rest )*),
|
||||
outer_dispatch: Self::outer_dispatch_metadata(),
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +105,7 @@ mod tests {
|
||||
StorageFunctionModifier, StorageFunctionType, FunctionMetadata,
|
||||
StorageMetadata, StorageFunctionMetadata, OuterDispatchMetadata, OuterDispatchCall
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
use codec::Decode;
|
||||
|
||||
mod system {
|
||||
pub trait Trait {
|
||||
@@ -344,12 +346,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn runtime_metadata() {
|
||||
let metadata = TestRuntime::metadata();
|
||||
assert_eq!(EXPECTED_METADATA, metadata);
|
||||
|
||||
let metadata_encoded = metadata.encode();
|
||||
let metadata_encoded = TestRuntime::metadata();
|
||||
let metadata_decoded = RuntimeMetadata::decode(&mut &metadata_encoded[..]);
|
||||
|
||||
assert_eq!(metadata, metadata_decoded.unwrap());
|
||||
assert_eq!(EXPECTED_METADATA, metadata_decoded.unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user