mirror of
https://github.com/pezkuwichain/pezframe-metadata.git
synced 2026-06-14 15:41:03 +00:00
Update to latest scale-info & codec, remove string parameterization (#7)
* Update to latest scale-info & codec, remove string parameterization * Remove redundant bound * Remove more redundant S bounds * Use substrate branch * Use latest scale-info release
This commit is contained in:
@@ -13,9 +13,9 @@ readme = "README.md"
|
|||||||
targets = ["x86_64-unknown-linux-gnu"]
|
targets = ["x86_64-unknown-linux-gnu"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
|
codec = { package = "parity-scale-codec", version = "2.0.0", default-features = false, features = ["derive"] }
|
||||||
cfg-if = "1.0.0"
|
cfg-if = "1.0.0"
|
||||||
scale-info = { git = "https://github.com/paritytech/scale-info", default-features = false, optional = true, features = ["derive"] }
|
scale-info = { version = "0.6.0", default-features = false, optional = true, features = ["derive"] }
|
||||||
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
serde = { version = "1.0.101", optional = true, features = ["derive"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
@@ -26,5 +26,6 @@ std = [
|
|||||||
"codec/std",
|
"codec/std",
|
||||||
"scale-info/std",
|
"scale-info/std",
|
||||||
"scale-info/serde",
|
"scale-info/serde",
|
||||||
|
"scale-info/decode",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -40,25 +40,10 @@ pub mod v12;
|
|||||||
#[cfg(feature = "v13")]
|
#[cfg(feature = "v13")]
|
||||||
pub mod v13;
|
pub mod v13;
|
||||||
|
|
||||||
cfg_if::cfg_if! {
|
|
||||||
if #[cfg(not(feature = "v13"))] {
|
|
||||||
/// Dummy trait in place of `scale_info::form::FormString`.
|
|
||||||
/// Since the `scale-info` crate is only imported for the `v13` feature.
|
|
||||||
pub trait FormString {}
|
|
||||||
|
|
||||||
impl FormString for &'static str {}
|
|
||||||
#[cfg(feature = "std")]
|
|
||||||
impl FormString for String {}
|
|
||||||
} else {
|
|
||||||
pub(crate) use scale_info::form::FormString;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Metadata prefixed by a u32 for reserved usage
|
/// Metadata prefixed by a u32 for reserved usage
|
||||||
#[derive(Eq, Encode, PartialEq)]
|
#[derive(Eq, Encode, PartialEq)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))]
|
pub struct RuntimeMetadataPrefixed(pub u32, pub RuntimeMetadata);
|
||||||
pub struct RuntimeMetadataPrefixed<S: FormString = &'static str>(pub u32, pub RuntimeMetadata<S>);
|
|
||||||
|
|
||||||
impl Into<Vec<u8>> for RuntimeMetadataPrefixed {
|
impl Into<Vec<u8>> for RuntimeMetadataPrefixed {
|
||||||
fn into(self) -> Vec<u8> {
|
fn into(self) -> Vec<u8> {
|
||||||
@@ -71,10 +56,9 @@ impl Into<Vec<u8>> for RuntimeMetadataPrefixed {
|
|||||||
/// the enum nature of `RuntimeMetadata`.
|
/// the enum nature of `RuntimeMetadata`.
|
||||||
#[derive(Eq, Encode, PartialEq)]
|
#[derive(Eq, Encode, PartialEq)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))]
|
pub enum RuntimeMetadata {
|
||||||
pub enum RuntimeMetadata<S: FormString = &'static str> {
|
|
||||||
/// Unused; enum filler.
|
/// Unused; enum filler.
|
||||||
V0(core::marker::PhantomData<S>),
|
V0(RuntimeMetadataDeprecated),
|
||||||
/// Version 1 for runtime metadata. No longer used.
|
/// Version 1 for runtime metadata. No longer used.
|
||||||
V1(RuntimeMetadataDeprecated),
|
V1(RuntimeMetadataDeprecated),
|
||||||
/// Version 2 for runtime metadata. No longer used.
|
/// Version 2 for runtime metadata. No longer used.
|
||||||
@@ -99,13 +83,13 @@ pub enum RuntimeMetadata<S: FormString = &'static str> {
|
|||||||
V11(RuntimeMetadataDeprecated),
|
V11(RuntimeMetadataDeprecated),
|
||||||
/// Version 12 for runtime metadata
|
/// Version 12 for runtime metadata
|
||||||
#[cfg(feature = "v12")]
|
#[cfg(feature = "v12")]
|
||||||
V12(v12::RuntimeMetadataV12<S>),
|
V12(v12::RuntimeMetadataV12),
|
||||||
/// Version 12 for runtime metadata, as raw encoded bytes.
|
/// Version 12 for runtime metadata, as raw encoded bytes.
|
||||||
#[cfg(not(feature = "v12"))]
|
#[cfg(not(feature = "v12"))]
|
||||||
V12(OpaqueMetadata),
|
V12(OpaqueMetadata),
|
||||||
/// Version 13 for runtime metadata.
|
/// Version 13 for runtime metadata.
|
||||||
#[cfg(feature = "v13")]
|
#[cfg(feature = "v13")]
|
||||||
V13(v13::RuntimeMetadataV13<S>),
|
V13(v13::RuntimeMetadataV13),
|
||||||
/// Version 13 for runtime metadata, as raw encoded bytes.
|
/// Version 13 for runtime metadata, as raw encoded bytes.
|
||||||
#[cfg(not(feature = "v13"))]
|
#[cfg(not(feature = "v13"))]
|
||||||
V13(OpaqueMetadata),
|
V13(OpaqueMetadata),
|
||||||
@@ -122,7 +106,7 @@ pub struct OpaqueMetadata(pub Vec<u8>);
|
|||||||
pub enum RuntimeMetadataDeprecated {}
|
pub enum RuntimeMetadataDeprecated {}
|
||||||
|
|
||||||
impl Encode for RuntimeMetadataDeprecated {
|
impl Encode for RuntimeMetadataDeprecated {
|
||||||
fn encode_to<W: Output>(&self, _dest: &mut W) {}
|
fn encode_to<W: Output + ?Sized>(&self, _dest: &mut W) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl codec::EncodeLike for RuntimeMetadataDeprecated {}
|
impl codec::EncodeLike for RuntimeMetadataDeprecated {}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ where
|
|||||||
B: Encode + 'static,
|
B: Encode + 'static,
|
||||||
O: Encode + 'static,
|
O: Encode + 'static,
|
||||||
{
|
{
|
||||||
fn encode_to<W: Output>(&self, dest: &mut W) {
|
fn encode_to<W: Output + ?Sized>(&self, dest: &mut W) {
|
||||||
match self {
|
match self {
|
||||||
DecodeDifferent::Encode(b) => b.encode_to(dest),
|
DecodeDifferent::Encode(b) => b.encode_to(dest),
|
||||||
DecodeDifferent::Decoded(o) => o.encode_to(dest),
|
DecodeDifferent::Decoded(o) => o.encode_to(dest),
|
||||||
@@ -160,7 +160,7 @@ where
|
|||||||
E: Encode + 'static;
|
E: Encode + 'static;
|
||||||
|
|
||||||
impl<E: Encode> Encode for FnEncode<E> {
|
impl<E: Encode> Encode for FnEncode<E> {
|
||||||
fn encode_to<W: Output>(&self, dest: &mut W) {
|
fn encode_to<W: Output + ?Sized>(&self, dest: &mut W) {
|
||||||
self.0().encode_to(dest);
|
self.0().encode_to(dest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,7 +262,7 @@ pub struct DefaultByteGetter(pub &'static dyn DefaultByte);
|
|||||||
pub type ByteGetter = DecodeDifferent<DefaultByteGetter, Vec<u8>>;
|
pub type ByteGetter = DecodeDifferent<DefaultByteGetter, Vec<u8>>;
|
||||||
|
|
||||||
impl Encode for DefaultByteGetter {
|
impl Encode for DefaultByteGetter {
|
||||||
fn encode_to<W: Output>(&self, dest: &mut W) {
|
fn encode_to<W: Output + ?Sized>(&self, dest: &mut W) {
|
||||||
self.0.default_byte().encode_to(dest)
|
self.0.default_byte().encode_to(dest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,7 +359,6 @@ pub struct ExtrinsicMetadata {
|
|||||||
/// The metadata of a runtime.
|
/// The metadata of a runtime.
|
||||||
#[derive(Eq, Encode, PartialEq)]
|
#[derive(Eq, Encode, PartialEq)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))]
|
|
||||||
pub struct RuntimeMetadataV12<S = ()> {
|
pub struct RuntimeMetadataV12<S = ()> {
|
||||||
/// Metadata of all the modules.
|
/// Metadata of all the modules.
|
||||||
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
pub modules: DecodeDifferentArray<ModuleMetadata>,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use super::RuntimeMetadataPrefixed;
|
|||||||
use codec::Encode;
|
use codec::Encode;
|
||||||
use scale_info::prelude::vec::Vec;
|
use scale_info::prelude::vec::Vec;
|
||||||
use scale_info::{
|
use scale_info::{
|
||||||
form::{Form, FormString, MetaForm, PortableForm},
|
form::{Form, MetaForm, PortableForm},
|
||||||
meta_type, IntoPortable, PortableRegistry, Registry, TypeInfo,
|
meta_type, IntoPortable, PortableRegistry, Registry, TypeInfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -48,13 +48,12 @@ impl From<RuntimeMetadataLastVersion> for super::RuntimeMetadataPrefixed {
|
|||||||
// todo: [AJ] add back clone derive if required (requires PortableRegistry to implement clone)
|
// todo: [AJ] add back clone derive if required (requires PortableRegistry to implement clone)
|
||||||
#[derive(PartialEq, Eq, Encode)]
|
#[derive(PartialEq, Eq, Encode)]
|
||||||
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))]
|
||||||
#[cfg_attr(feature = "std", serde(bound(serialize = "S: Serialize")))]
|
pub struct RuntimeMetadataV13 {
|
||||||
pub struct RuntimeMetadataV13<S: FormString = &'static str> {
|
pub types: PortableRegistry,
|
||||||
pub types: PortableRegistry<S>,
|
|
||||||
/// Metadata of all the modules.
|
/// Metadata of all the modules.
|
||||||
pub modules: Vec<ModuleMetadata<PortableForm<S>>>,
|
pub modules: Vec<ModuleMetadata<PortableForm>>,
|
||||||
/// Metadata of the extrinsic.
|
/// Metadata of the extrinsic.
|
||||||
pub extrinsic: ExtrinsicMetadata<PortableForm<S>>,
|
pub extrinsic: ExtrinsicMetadata<PortableForm>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RuntimeMetadataV13 {
|
impl RuntimeMetadataV13 {
|
||||||
|
|||||||
Reference in New Issue
Block a user