mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 08:21:05 +00:00
Metadata V15: Derive TypeInfo for describing runtime types (#13272)
* scale_info: Derive TypeInfo for types present in runtime API Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * cargo: Update Cargo.lock Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Generated
+3
@@ -5615,6 +5615,7 @@ version = "7.0.0"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
"sp-weights",
|
||||
@@ -8151,6 +8152,7 @@ dependencies = [
|
||||
"sc-network",
|
||||
"sc-network-test",
|
||||
"sc-telemetry",
|
||||
"scale-info",
|
||||
"schnorrkel",
|
||||
"sp-api",
|
||||
"sp-application-crypto",
|
||||
@@ -9959,6 +9961,7 @@ dependencies = [
|
||||
"futures",
|
||||
"impl-trait-for-tuples",
|
||||
"parity-scale-codec",
|
||||
"scale-info",
|
||||
"sp-core",
|
||||
"sp-runtime",
|
||||
"sp-std",
|
||||
|
||||
@@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
async-trait = "0.1.57"
|
||||
scale-info = { version = "2.1.1", features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", features = ["derive"] }
|
||||
futures = "0.3.21"
|
||||
log = "0.4.17"
|
||||
|
||||
@@ -152,7 +152,7 @@ mod tests;
|
||||
const LOG_TARGET: &str = "babe";
|
||||
|
||||
/// BABE epoch information
|
||||
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, scale_info::TypeInfo)]
|
||||
pub struct Epoch {
|
||||
/// The epoch index.
|
||||
pub epoch_index: u64,
|
||||
|
||||
@@ -22,6 +22,7 @@ use frame_support::{
|
||||
pallet_prelude::*,
|
||||
traits::StorageInfo,
|
||||
};
|
||||
use scale_info::TypeInfo;
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sp_io::hashing::blake2_256;
|
||||
@@ -31,7 +32,7 @@ use sp_storage::TrackedStorageKey;
|
||||
|
||||
/// An alphabet of possible parameters to use for benchmarking.
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
#[derive(Encode, Decode, Clone, Copy, PartialEq, Debug)]
|
||||
#[derive(Encode, Decode, Clone, Copy, PartialEq, Debug, TypeInfo)]
|
||||
#[allow(missing_docs)]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub enum BenchmarkParameter {
|
||||
@@ -72,7 +73,7 @@ impl std::fmt::Display for BenchmarkParameter {
|
||||
|
||||
/// The results of a single of benchmark.
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Debug)]
|
||||
#[derive(Encode, Decode, Clone, PartialEq, Debug, TypeInfo)]
|
||||
pub struct BenchmarkBatch {
|
||||
/// The pallet containing this benchmark.
|
||||
#[cfg_attr(feature = "std", serde(with = "serde_as_str"))]
|
||||
@@ -111,7 +112,7 @@ pub struct BenchmarkBatchSplitResults {
|
||||
/// Contains duration of the function call in nanoseconds along with the benchmark parameters
|
||||
/// used for that benchmark result.
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)]
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
|
||||
pub struct BenchmarkResult {
|
||||
pub components: Vec<(BenchmarkParameter, u32)>,
|
||||
pub extrinsic_time: u128,
|
||||
@@ -199,7 +200,7 @@ impl From<DispatchError> for BenchmarkError {
|
||||
}
|
||||
|
||||
/// Configuration used to setup and run runtime benchmarks.
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)]
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
|
||||
pub struct BenchmarkConfig {
|
||||
/// The encoded name of the pallet to benchmark.
|
||||
pub pallet: Vec<u8>,
|
||||
@@ -216,14 +217,14 @@ pub struct BenchmarkConfig {
|
||||
/// A list of benchmarks available for a particular pallet and instance.
|
||||
///
|
||||
/// All `Vec<u8>` must be valid utf8 strings.
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)]
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
|
||||
pub struct BenchmarkList {
|
||||
pub pallet: Vec<u8>,
|
||||
pub instance: Vec<u8>,
|
||||
pub benchmarks: Vec<BenchmarkMetadata>,
|
||||
}
|
||||
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug)]
|
||||
#[derive(Encode, Decode, Default, Clone, PartialEq, Debug, TypeInfo)]
|
||||
pub struct BenchmarkMetadata {
|
||||
pub name: Vec<u8>,
|
||||
pub components: Vec<(BenchmarkParameter, u32, u32)>,
|
||||
|
||||
@@ -14,6 +14,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
|
||||
[dependencies]
|
||||
bitflags = "1.0"
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
|
||||
|
||||
# Substrate Dependencies (This crate should not rely on frame)
|
||||
@@ -27,4 +28,5 @@ std = [
|
||||
"codec/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
"scale-info/std",
|
||||
]
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
use bitflags::bitflags;
|
||||
use codec::{Decode, Encode};
|
||||
use scale_info::TypeInfo;
|
||||
use sp_runtime::{
|
||||
traits::{Saturating, Zero},
|
||||
DispatchError, RuntimeDebug,
|
||||
@@ -31,7 +32,7 @@ use sp_weights::Weight;
|
||||
/// Result type of a `bare_call` or `bare_instantiate` call.
|
||||
///
|
||||
/// It contains the execution result together with some auxiliary information.
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct ContractResult<R, Balance> {
|
||||
/// How much weight was consumed during execution.
|
||||
pub gas_consumed: Weight,
|
||||
@@ -86,7 +87,7 @@ pub type CodeUploadResult<CodeHash, Balance> =
|
||||
pub type GetStorageResult = Result<Option<Vec<u8>>, ContractAccessError>;
|
||||
|
||||
/// The possible errors that can happen querying the storage of a contract.
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub enum ContractAccessError {
|
||||
/// The given address doesn't point to a contract.
|
||||
DoesntExist,
|
||||
@@ -96,7 +97,7 @@ pub enum ContractAccessError {
|
||||
|
||||
bitflags! {
|
||||
/// Flags used by a contract to customize exit behaviour.
|
||||
#[derive(Encode, Decode)]
|
||||
#[derive(Encode, Decode, TypeInfo)]
|
||||
pub struct ReturnFlags: u32 {
|
||||
/// If this bit is set all changes made by the contract execution are rolled back.
|
||||
const REVERT = 0x0000_0001;
|
||||
@@ -104,7 +105,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
/// Output of a contract call or instantiation which ran to completion.
|
||||
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct ExecReturnValue {
|
||||
/// Flags passed along by `seal_return`. Empty when `seal_return` was never called.
|
||||
pub flags: ReturnFlags,
|
||||
@@ -120,7 +121,7 @@ impl ExecReturnValue {
|
||||
}
|
||||
|
||||
/// The result of a successful contract instantiation.
|
||||
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct InstantiateReturnValue<AccountId> {
|
||||
/// The output of the called constructor.
|
||||
pub result: ExecReturnValue,
|
||||
@@ -129,7 +130,7 @@ pub struct InstantiateReturnValue<AccountId> {
|
||||
}
|
||||
|
||||
/// The result of succesfully uploading a contract.
|
||||
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct CodeUploadReturnValue<CodeHash, Balance> {
|
||||
/// The key under which the new code is stored.
|
||||
pub code_hash: CodeHash,
|
||||
@@ -138,7 +139,7 @@ pub struct CodeUploadReturnValue<CodeHash, Balance> {
|
||||
}
|
||||
|
||||
/// Reference to an existing code hash or a new wasm module.
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(Eq, PartialEq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub enum Code<Hash> {
|
||||
/// A wasm module as raw bytes.
|
||||
Upload(Vec<u8>),
|
||||
@@ -153,7 +154,7 @@ impl<T: Into<Vec<u8>>, Hash> From<T> for Code<Hash> {
|
||||
}
|
||||
|
||||
/// The amount of balance that was either charged or refunded in order to pay for storage.
|
||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, Clone)]
|
||||
#[derive(Eq, PartialEq, Ord, PartialOrd, Encode, Decode, RuntimeDebug, Clone, TypeInfo)]
|
||||
pub enum StorageDeposit<Balance> {
|
||||
/// The transaction reduced storage consumption.
|
||||
///
|
||||
|
||||
@@ -53,7 +53,9 @@ pub trait StorageInstance {
|
||||
}
|
||||
|
||||
/// Metadata about storage from the runtime.
|
||||
#[derive(codec::Encode, codec::Decode, crate::RuntimeDebug, Eq, PartialEq, Clone)]
|
||||
#[derive(
|
||||
codec::Encode, codec::Decode, crate::RuntimeDebug, Eq, PartialEq, Clone, scale_info::TypeInfo,
|
||||
)]
|
||||
pub struct StorageInfo {
|
||||
/// Encoded string of pallet name.
|
||||
pub pallet_name: Vec<u8>,
|
||||
|
||||
@@ -22,7 +22,7 @@ use sp_arithmetic::traits::AtLeast32BitUnsigned;
|
||||
use sp_std::prelude::*;
|
||||
|
||||
/// Which state tests to execute.
|
||||
#[derive(codec::Encode, codec::Decode, Clone)]
|
||||
#[derive(codec::Encode, codec::Decode, Clone, scale_info::TypeInfo)]
|
||||
pub enum Select {
|
||||
/// None of them.
|
||||
None,
|
||||
@@ -82,7 +82,7 @@ impl sp_std::str::FromStr for Select {
|
||||
}
|
||||
|
||||
/// Select which checks should be run when trying a runtime upgrade upgrade.
|
||||
#[derive(codec::Encode, codec::Decode, Clone, Debug, Copy)]
|
||||
#[derive(codec::Encode, codec::Decode, Clone, Debug, Copy, scale_info::TypeInfo)]
|
||||
pub enum UpgradeCheckSelect {
|
||||
/// Run no checks.
|
||||
None,
|
||||
|
||||
@@ -21,13 +21,15 @@ use codec::{Decode, Encode};
|
||||
#[cfg(feature = "std")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use scale_info::TypeInfo;
|
||||
|
||||
use sp_runtime::traits::{AtLeast32BitUnsigned, Zero};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
use frame_support::dispatch::DispatchClass;
|
||||
|
||||
/// The base fee and adjusted weight and length fees constitute the _inclusion fee_.
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
pub struct InclusionFee<Balance> {
|
||||
@@ -63,7 +65,7 @@ impl<Balance: AtLeast32BitUnsigned + Copy> InclusionFee<Balance> {
|
||||
/// - (Optional) `inclusion_fee`: Only the `Pays::Yes` transaction can have the inclusion fee.
|
||||
/// - `tip`: If included in the transaction, the tip will be added on top. Only signed
|
||||
/// transactions can have a tip.
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq)]
|
||||
#[derive(Encode, Decode, Clone, Eq, PartialEq, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
pub struct FeeDetails<Balance> {
|
||||
@@ -91,7 +93,7 @@ impl<Balance: AtLeast32BitUnsigned + Copy> FeeDetails<Balance> {
|
||||
|
||||
/// Information related to a dispatchable's class, weight, and fee that can be queried from the
|
||||
/// runtime.
|
||||
#[derive(Eq, PartialEq, Encode, Decode, Default)]
|
||||
#[derive(Eq, PartialEq, Encode, Decode, Default, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
#[cfg_attr(
|
||||
|
||||
@@ -184,7 +184,7 @@ impl From<BabeConfigurationV1> for BabeConfiguration {
|
||||
}
|
||||
|
||||
/// Configuration data used by the BABE consensus engine.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct BabeConfiguration {
|
||||
/// The slot duration in milliseconds for BABE. Currently, only
|
||||
/// the value provided by this type at genesis will be used.
|
||||
@@ -327,7 +327,7 @@ where
|
||||
/// the runtime API boundary this type is unknown and as such we keep this
|
||||
/// opaque representation, implementors of the runtime API will have to make
|
||||
/// sure that all usages of `OpaqueKeyOwnershipProof` refer to the same type.
|
||||
#[derive(Decode, Encode, PartialEq)]
|
||||
#[derive(Decode, Encode, PartialEq, TypeInfo)]
|
||||
pub struct OpaqueKeyOwnershipProof(Vec<u8>);
|
||||
impl OpaqueKeyOwnershipProof {
|
||||
/// Create a new `OpaqueKeyOwnershipProof` using the given encoded
|
||||
@@ -344,7 +344,7 @@ impl OpaqueKeyOwnershipProof {
|
||||
}
|
||||
|
||||
/// BABE epoch information
|
||||
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug)]
|
||||
#[derive(Decode, Encode, PartialEq, Eq, Clone, Debug, TypeInfo)]
|
||||
pub struct Epoch {
|
||||
/// The epoch index.
|
||||
pub epoch_index: u64,
|
||||
|
||||
@@ -165,7 +165,7 @@ impl sp_std::str::FromStr for Bytes {
|
||||
}
|
||||
|
||||
/// Stores the encoded `RuntimeMetadata` for the native side as opaque type.
|
||||
#[derive(Encode, Decode, PartialEq)]
|
||||
#[derive(Encode, Decode, PartialEq, TypeInfo)]
|
||||
pub struct OpaqueMetadata(Vec<u8>);
|
||||
|
||||
impl OpaqueMetadata {
|
||||
|
||||
@@ -529,7 +529,7 @@ impl<'a> Decode for VersionedAuthorityList<'a> {
|
||||
/// the runtime API boundary this type is unknown and as such we keep this
|
||||
/// opaque representation, implementors of the runtime API will have to make
|
||||
/// sure that all usages of `OpaqueKeyOwnershipProof` refer to the same type.
|
||||
#[derive(Decode, Encode, PartialEq)]
|
||||
#[derive(Decode, Encode, PartialEq, TypeInfo)]
|
||||
pub struct OpaqueKeyOwnershipProof(Vec<u8>);
|
||||
|
||||
impl OpaqueKeyOwnershipProof {
|
||||
|
||||
@@ -16,6 +16,7 @@ targets = ["x86_64-unknown-linux-gnu"]
|
||||
[dependencies]
|
||||
async-trait = { version = "0.1.57", optional = true }
|
||||
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
|
||||
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
|
||||
impl-trait-for-tuples = "0.2.2"
|
||||
thiserror = { version = "1.0.30", optional = true }
|
||||
sp-core = { version = "7.0.0", default-features = false, path = "../core" }
|
||||
@@ -30,6 +31,7 @@ default = [ "std" ]
|
||||
std = [
|
||||
"async-trait",
|
||||
"codec/std",
|
||||
"scale-info/std",
|
||||
"sp-core/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
|
||||
@@ -204,7 +204,7 @@ pub enum Error {
|
||||
pub type InherentIdentifier = [u8; 8];
|
||||
|
||||
/// Inherent data to include in a block.
|
||||
#[derive(Clone, Default, Encode, Decode)]
|
||||
#[derive(Clone, Default, Encode, Decode, scale_info::TypeInfo)]
|
||||
pub struct InherentData {
|
||||
/// All inherent data encoded with parity-scale-codec and an identifier.
|
||||
data: BTreeMap<InherentIdentifier, Vec<u8>>,
|
||||
@@ -276,7 +276,7 @@ impl InherentData {
|
||||
///
|
||||
/// When a fatal error occurs, all other errors are removed and the implementation needs to
|
||||
/// abort checking inherents.
|
||||
#[derive(Encode, Decode, Clone)]
|
||||
#[derive(Encode, Decode, Clone, scale_info::TypeInfo)]
|
||||
pub struct CheckInherentsResult {
|
||||
/// Did the check succeed?
|
||||
okay: bool,
|
||||
|
||||
@@ -142,7 +142,7 @@ impl FullLeaf for OpaqueLeaf {
|
||||
///
|
||||
/// It is different from [`OpaqueLeaf`], because it does implement `Codec`
|
||||
/// and the encoding has to match raw `Vec<u8>` encoding.
|
||||
#[derive(codec::Encode, codec::Decode, RuntimeDebug, PartialEq, Eq)]
|
||||
#[derive(codec::Encode, codec::Decode, RuntimeDebug, PartialEq, Eq, TypeInfo)]
|
||||
pub struct EncodableOpaqueLeaf(pub Vec<u8>);
|
||||
|
||||
impl EncodableOpaqueLeaf {
|
||||
@@ -361,7 +361,7 @@ pub struct Proof<Hash> {
|
||||
|
||||
/// Merkle Mountain Range operation error.
|
||||
#[cfg_attr(feature = "std", derive(thiserror::Error))]
|
||||
#[derive(RuntimeDebug, codec::Encode, codec::Decode, PartialEq, Eq)]
|
||||
#[derive(RuntimeDebug, codec::Encode, codec::Decode, PartialEq, Eq, TypeInfo)]
|
||||
pub enum Error {
|
||||
/// Error during translation of a block number into a leaf index.
|
||||
#[cfg_attr(feature = "std", error("Error performing numeric op"))]
|
||||
|
||||
@@ -78,7 +78,7 @@ impl<Block: BlockT> fmt::Display for BlockId<Block> {
|
||||
}
|
||||
|
||||
/// Abstraction over a substrate block.
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(PartialEq, Eq, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))]
|
||||
#[cfg_attr(feature = "std", serde(deny_unknown_fields))]
|
||||
|
||||
@@ -226,7 +226,7 @@ impl From<UnknownTransaction> for TransactionValidity {
|
||||
/// Depending on the source we might apply different validation schemes.
|
||||
/// For instance we can disallow specific kinds of transactions if they were not produced
|
||||
/// by our local node (for instance off-chain workers).
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub enum TransactionSource {
|
||||
/// Transaction is already included in block.
|
||||
///
|
||||
@@ -251,7 +251,7 @@ pub enum TransactionSource {
|
||||
}
|
||||
|
||||
/// Information concerning a valid transaction.
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug)]
|
||||
#[derive(Clone, PartialEq, Eq, Encode, Decode, RuntimeDebug, TypeInfo)]
|
||||
pub struct ValidTransaction {
|
||||
/// Priority of the transaction.
|
||||
///
|
||||
|
||||
@@ -297,7 +297,7 @@ pub fn run_tests(mut input: &[u8]) -> Vec<u8> {
|
||||
}
|
||||
|
||||
/// A type that can not be decoded.
|
||||
#[derive(PartialEq)]
|
||||
#[derive(PartialEq, TypeInfo)]
|
||||
pub struct DecodeFails<B: BlockT> {
|
||||
_phantom: PhantomData<B>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user