Skip to content

Commit

Permalink
Add metadata V15 with Runtime API support (#48)
Browse files Browse the repository at this point in the history
* v15: Add everything from v14

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Add feature to make the V15 the default version

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Add trait metadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Add method metadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Add param metadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Constructor for the metadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v14: Keep backwards compatibility with v14 re-exports

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Add trait and method documentation

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Make trait version optional

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Do not reexport v14 types

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Expose metadata as unstable

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Exclude trait versioning from metadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Add pallet documentation

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Rename runtime API structs

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* v15: Rename `ParamMetadata` to RuntimeApiMethodParamMetadata

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Update frame-metadata/src/v15.rs

Co-authored-by: Bastian Köcher <git@kchr.de>

* v15: Reanme `runtime` -> `apis` and use global META_RESERVED

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* lib: Force CI by better docs

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* Copyright: Align copyright with substrate

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: Bastian Köcher <git@kchr.de>
  • Loading branch information
lexnv and bkchr authored Mar 30, 2023
1 parent 040a53c commit a09bd49
Show file tree
Hide file tree
Showing 10 changed files with 539 additions and 24 deletions.
1 change: 1 addition & 0 deletions frame-metadata/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ v12 = []
v13 = []
legacy = ["v13", "v12", "v11", "v10", "v9", "v8"]
v14 = ["scale-info"]
v15-unstable = ["scale-info"]

# Serde support without relying on std features
serde_full = [
Expand Down
4 changes: 1 addition & 3 deletions frame-metadata/src/decode_different.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file is part of Substrate.

// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
18 changes: 15 additions & 3 deletions frame-metadata/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file is part of Substrate.

// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -89,12 +87,19 @@ pub mod v13;
#[cfg(feature = "v14")]
pub mod v14;

/// Metadata v15
#[cfg(feature = "v15-unstable")]
pub mod v15;

// Reexport all the types from the latest version.
//
// When a new version becomes available, update this.
#[cfg(feature = "v14")]
pub use self::v14::*;

/// Metadata prefix.
pub const META_RESERVED: u32 = 0x6174656d; // 'meta' warning for endianness.

/// Metadata prefixed by a u32 for reserved usage
#[derive(Eq, Encode, PartialEq, Debug)]
#[cfg_attr(feature = "decode", derive(Decode))]
Expand Down Expand Up @@ -172,6 +177,12 @@ pub enum RuntimeMetadata {
/// Version 14 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v14"))]
V14(OpaqueMetadata),
/// Version 15 for runtime metadata.
#[cfg(feature = "v15-unstable")]
V15(v15::RuntimeMetadataV15),
/// Version 15 for runtime metadata, as raw encoded bytes.
#[cfg(not(feature = "v15-unstable"))]
V15(OpaqueMetadata),
}

impl RuntimeMetadata {
Expand All @@ -193,6 +204,7 @@ impl RuntimeMetadata {
RuntimeMetadata::V12(_) => 12,
RuntimeMetadata::V13(_) => 13,
RuntimeMetadata::V14(_) => 14,
RuntimeMetadata::V15(_) => 15,
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions frame-metadata/src/v10.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file is part of Substrate.

// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 1 addition & 3 deletions frame-metadata/src/v11.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file is part of Substrate.

// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 1 addition & 3 deletions frame-metadata/src/v12.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file is part of Substrate.

// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
4 changes: 1 addition & 3 deletions frame-metadata/src/v14.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file is part of Substrate.

// Copyright (C) 2018-2020 Parity Technologies (UK) Ltd.
// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
Loading

0 comments on commit a09bd49

Please sign in to comment.