v15: Rename error_enum_ty to module_error_enum_ty (#60)

* v15: Rename `error_enum_ty` to `module_error_enum_ty`

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

* v15: Rename RuntimeMetadataV15 params

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

* Update frame-metadata/src/v15.rs

Co-authored-by: James Wilson <james@jsdw.me>

* Update frame-metadata/src/v15.rs

Co-authored-by: James Wilson <james@jsdw.me>

* Apply fmt

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

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
Co-authored-by: James Wilson <james@jsdw.me>
This commit is contained in:
Alexandru Vasile
2023-06-13 14:05:27 +03:00
committed by GitHub
parent 0c6400964f
commit 426ba93c56
+19 -5
View File
@@ -54,8 +54,22 @@ pub struct RuntimeMetadataV15 {
pub call_enum_ty: <PortableForm as Form>::Type,
/// The type of the outer `RuntimeEvent` enum.
pub event_enum_ty: <PortableForm as Form>::Type,
/// The type of the outer `RuntimeError` enum.
pub error_enum_ty: <PortableForm as Form>::Type,
/// The module error type of the
/// [`DispatchError::Module`](https://docs.rs/sp-runtime/24.0.0/sp_runtime/enum.DispatchError.html#variant.Module) variant.
///
/// The `Module` variant will be 5 scale encoded bytes which are normally decoded into
/// an `{ index: u8, error: [u8; 4] }` struct. This type ID points to an enum type which instead
/// interprets the first `index` byte as a pallet variant, and the remaining `error` bytes as the
/// appropriate `pallet::Error` type. It is an equally valid way to decode the error bytes, and
/// can be more informative.
///
/// # Note
///
/// - This type cannot be used directly to decode `sp_runtime::DispatchError` from the
/// chain. It provides just the information needed to decode `sp_runtime::DispatchError::Module`.
/// - Decoding the 5 error bytes into this type will not always lead to all of the bytes being consumed;
/// many error types do not require all of the bytes to represent them fully.
pub module_error_enum_ty: <PortableForm as Form>::Type,
}
impl RuntimeMetadataV15 {
@@ -67,7 +81,7 @@ impl RuntimeMetadataV15 {
apis: Vec<RuntimeApiMetadata>,
call_enum_ty: MetaType,
event_enum_ty: MetaType,
error_enum_ty: MetaType,
module_error_enum_ty: MetaType,
) -> Self {
let mut registry = Registry::new();
let pallets = registry.map_into_portable(pallets);
@@ -76,7 +90,7 @@ impl RuntimeMetadataV15 {
let apis = registry.map_into_portable(apis);
let call_enum_ty = registry.register_type(&call_enum_ty);
let event_enum_ty = registry.register_type(&event_enum_ty);
let error_enum_ty = registry.register_type(&error_enum_ty);
let module_error_enum_ty = registry.register_type(&module_error_enum_ty);
Self {
types: registry.into(),
pallets,
@@ -85,7 +99,7 @@ impl RuntimeMetadataV15 {
apis,
call_enum_ty,
event_enum_ty,
error_enum_ty,
module_error_enum_ty,
}
}
}