Implement support for renaming runtime api functions (#2160)

* Implement support for renaming runtime api functions

* Redelete the wasm files

* FIxes test

* Fix test correctly...

* Bring back old `authorities`

* Tag as deprecated

* Fixes compilation on WASM

* Add missing method implementations

* Fixes tests

* Increase `spec_version`
This commit is contained in:
Bastian Köcher
2019-04-02 10:05:35 +02:00
committed by Gav Wood
parent e89ce263bd
commit 345145326b
13 changed files with 288 additions and 81 deletions
+7
View File
@@ -35,6 +35,7 @@ pub use runtime_version::{ApiId, RuntimeVersion, ApisVec, create_apis_vec};
pub use rstd::{slice, mem};
#[cfg(feature = "std")]
use rstd::result;
#[doc(hidden)]
pub use parity_codec::{Encode, Decode};
#[cfg(feature = "std")]
use crate::error;
@@ -42,6 +43,7 @@ use sr_api_macros::decl_runtime_apis;
use primitives::OpaqueMetadata;
#[cfg(feature = "std")]
use std::panic::UnwindSafe;
use rstd::vec::Vec;
/// Something that can be constructed to a runtime api.
#[cfg(feature = "std")]
@@ -113,13 +115,18 @@ pub trait CallRuntimeAt<Block: BlockT> {
decl_runtime_apis! {
/// The `Core` api trait that is mandatory for each runtime.
#[core_trait]
#[api_version(2)]
pub trait Core {
/// Returns the version of the runtime.
fn version() -> RuntimeVersion;
/// Execute the given block.
fn execute_block(block: Block);
/// Initialize a block with the given header.
#[renamed("initialise_block", 2)]
fn initialize_block(header: &<Block as BlockT>::Header);
/// Returns the authorities.
#[deprecated(since = "1.0", note = "Please switch to `AuthoritiesApi`.")]
fn authorities() -> Vec<AuthorityIdFor<Block>>;
}
/// The `Metadata` api trait that returns metadata for the runtime.