Obtain DispatchError::Module info dynamically (#453)

* Add error information back into metadata to roll back removal in #394

* Go back to obtaining runtime error info

* re-do codegen too to check that it's all gravy

* Convert DispatchError module errors into a module variant to make them easier to work with

* Fix broken doc link
This commit is contained in:
James Wilson
2022-02-17 13:45:57 +00:00
committed by GitHub
parent eeb8b4b741
commit e866d744de
10 changed files with 1670 additions and 1610 deletions
+4 -9
View File
@@ -265,9 +265,8 @@ impl RuntimeGenerator {
pallet.calls.as_ref().map(|_| pallet_mod_name)
});
let error_details = errors::generate_error_details(&self.metadata);
let error_type = error_details.type_def;
let error_fn = error_details.dispatch_error_impl_fn;
let has_module_error_impl =
errors::generate_has_module_error_impl(&self.metadata, types_mod_ident);
let default_account_data_ident = format_ident!("DefaultAccountData");
let default_account_data_impl = generate_default_account_data_impl(
@@ -291,12 +290,8 @@ impl RuntimeGenerator {
/// The default error type returned when there is a runtime issue.
pub type DispatchError = #types_mod_ident::sp_runtime::DispatchError;
// Statically generate error information so that we don't need runtime metadata for it.
#error_type
impl DispatchError {
#error_fn
}
// Impl HasModuleError on DispatchError so we can pluck out module error details.
#has_module_error_impl
#default_account_data_impl