diff --git a/frame-metadata/src/v13.rs b/frame-metadata/src/v13.rs index f3ced21..8f8a1a0 100644 --- a/frame-metadata/src/v13.rs +++ b/frame-metadata/src/v13.rs @@ -50,20 +50,20 @@ impl From for super::RuntimeMetadataPrefixed { #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] pub struct RuntimeMetadataV13 { pub types: PortableRegistry, - /// Metadata of all the modules. - pub modules: Vec>, + /// Metadata of all the pallets. + pub pallets: Vec>, /// Metadata of the extrinsic. pub extrinsic: ExtrinsicMetadata, } impl RuntimeMetadataV13 { - pub fn new(modules: Vec, extrinsic: ExtrinsicMetadata) -> Self { + pub fn new(pallets: Vec, extrinsic: ExtrinsicMetadata) -> Self { let mut registry = Registry::new(); - let modules = registry.map_into_portable(modules); + let pallets = registry.map_into_portable(pallets); let extrinsic = extrinsic.into_portable(&mut registry); Self { types: registry.into(), - modules, + pallets, extrinsic, } } @@ -122,59 +122,59 @@ impl IntoPortable for SignedExtensionMetadata { } } -/// All metadata about an runtime module. +/// All metadata about an runtime pallet. #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] #[cfg_attr( feature = "std", serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) )] -pub struct ModuleMetadata { +pub struct PalletMetadata { pub name: T::String, - pub storage: Option>, - pub calls: Option>>, - pub event: Option>>, - pub constants: Vec>, - pub errors: Vec>, - /// Define the index of the module, this index will be used for the encoding of module event, + pub storage: Option>, + pub calls: Option>, + pub event: Option>, + pub constants: Vec>, + pub error: Option>, + /// Define the index of the pallet, this index will be used for the encoding of pallet event, /// call and origin variants. pub index: u8, } -impl IntoPortable for ModuleMetadata { - type Output = ModuleMetadata; +impl IntoPortable for PalletMetadata { + type Output = PalletMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - ModuleMetadata { + PalletMetadata { name: self.name.into_portable(registry), storage: self.storage.map(|storage| storage.into_portable(registry)), - calls: self.calls.map(|calls| registry.map_into_portable(calls)), - event: self.event.map(|event| registry.map_into_portable(event)), + calls: self.calls.map(|calls| calls.into_portable(registry)), + event: self.event.map(|event| event.into_portable(registry)), constants: registry.map_into_portable(self.constants), - errors: registry.map_into_portable(self.errors), + error: self.error.map(|error| error.into_portable(registry)), index: self.index, } } } -/// All metadata of the storage. +/// All metadata of the pallet's storage. #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] #[cfg_attr( feature = "std", serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) )] -pub struct StorageMetadata { +pub struct PalletStorageMetadata { /// The common prefix used by all storage entries. pub prefix: T::String, pub entries: Vec>, } -impl IntoPortable for StorageMetadata { - type Output = StorageMetadata; +impl IntoPortable for PalletStorageMetadata { + type Output = PalletStorageMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - StorageMetadata { + PalletStorageMetadata { prefix: self.prefix.into_portable(registry), entries: registry.map_into_portable(self.entries), } @@ -290,144 +290,110 @@ impl IntoPortable for StorageEntryType { } } -/// All the metadata about a function. +/// Metadata for all calls in a pallet #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] #[cfg_attr( feature = "std", serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) )] -pub struct FunctionMetadata { - pub name: T::String, - pub arguments: Vec>, - pub documentation: Vec, -} - -impl IntoPortable for FunctionMetadata { - type Output = FunctionMetadata; - - fn into_portable(self, registry: &mut Registry) -> Self::Output { - FunctionMetadata { - name: self.name.into_portable(registry), - arguments: registry.map_into_portable(self.arguments), - documentation: registry.map_into_portable(self.documentation), - } - } -} - -/// All the metadata about a function argument. -#[derive(Clone, PartialEq, Eq, Encode)] -#[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr( - feature = "std", - serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) -)] -pub struct FunctionArgumentMetadata { - pub name: T::String, +pub struct PalletCallMetadata { + /// The corresponding enum type for the pallet call. pub ty: T::Type, + pub calls: Vec>, } -impl IntoPortable for FunctionArgumentMetadata { - type Output = FunctionArgumentMetadata; +impl IntoPortable for PalletCallMetadata { + type Output = PalletCallMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - FunctionArgumentMetadata { - name: self.name.into_portable(registry), + PalletCallMetadata { ty: registry.register_type(&self.ty), + calls: registry.map_into_portable(self.calls), } } } -/// All the metadata about an outer event. +/// All the metadata about a function. #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] #[cfg_attr( feature = "std", serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) )] -pub struct OuterEventMetadata { +pub struct FunctionMetadata { pub name: T::String, - pub events: Vec>, + pub arguments: Vec>, + pub documentation: Vec, } -impl IntoPortable for OuterEventMetadata { - type Output = OuterEventMetadata; +impl IntoPortable for FunctionMetadata { + type Output = FunctionMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - OuterEventMetadata { + FunctionMetadata { name: self.name.into_portable(registry), - events: registry.map_into_portable(self.events), + arguments: registry.map_into_portable(self.arguments), + documentation: registry.map_into_portable(self.documentation), } } } -/// Metadata about a module event. +/// All the metadata about a function argument. #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr( - feature = "std", - serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) -)] -pub struct ModuleEventMetadata { +pub struct FunctionArgumentMetadata { pub name: T::String, - pub events: Vec>, + pub ty: T::Type, } -impl IntoPortable for ModuleEventMetadata { - type Output = ModuleEventMetadata; +impl IntoPortable for FunctionArgumentMetadata { + type Output = FunctionArgumentMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - ModuleEventMetadata { + FunctionArgumentMetadata { name: self.name.into_portable(registry), - events: registry.map_into_portable(self.events), + ty: registry.register_type(&self.ty), } } } -/// All the metadata about an event. +/// Metadata about the pallet event type. #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr( - feature = "std", - serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) -)] -pub struct EventMetadata { - pub name: T::String, - pub arguments: Vec>, - pub documentation: Vec, +pub struct PalletEventMetadata { + pub ty: T::Type, } -impl IntoPortable for EventMetadata { - type Output = EventMetadata; +impl IntoPortable for PalletEventMetadata { + type Output = PalletEventMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - EventMetadata { - name: self.name.into_portable(registry), - arguments: registry.map_into_portable(self.arguments), - documentation: registry.map_into_portable(self.documentation), + PalletEventMetadata { + ty: registry.register_type(&self.ty), } } } -/// All the metadata about one module constant. +/// All the metadata about one pallet constant. #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] #[cfg_attr( feature = "std", serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) )] -pub struct ModuleConstantMetadata { +pub struct PalletConstantMetadata { pub name: T::String, pub ty: T::Type, pub value: ByteGetter, pub documentation: Vec, } -impl IntoPortable for ModuleConstantMetadata { - type Output = ModuleConstantMetadata; +impl IntoPortable for PalletConstantMetadata { + type Output = PalletConstantMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - ModuleConstantMetadata { + PalletConstantMetadata { name: self.name.into_portable(registry), ty: registry.register_type(&self.ty), value: self.value, @@ -436,25 +402,21 @@ impl IntoPortable for ModuleConstantMetadata { } } -/// All the metadata about a module error. +/// Metadata about a pallet error. #[derive(Clone, PartialEq, Eq, Encode)] #[cfg_attr(feature = "std", derive(Decode, Serialize, Debug))] -#[cfg_attr( - feature = "std", - serde(bound(serialize = "T::Type: Serialize, T::String: Serialize")) -)] -pub struct ErrorMetadata { - pub name: T::String, - pub documentation: Vec, +#[cfg_attr(feature = "std", serde(bound(serialize = "T::Type: Serialize")))] +pub struct PalletErrorMetadata { + /// The error type information. + pub ty: T::Type, } -impl IntoPortable for ErrorMetadata { - type Output = ErrorMetadata; +impl IntoPortable for PalletErrorMetadata { + type Output = PalletErrorMetadata; fn into_portable(self, registry: &mut Registry) -> Self::Output { - ErrorMetadata { - name: self.name.into_portable(registry), - documentation: registry.map_into_portable(self.documentation), + PalletErrorMetadata { + ty: registry.register_type(&self.ty), } } }