mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
feat: add configurable dispatch_error_module for rebranded chains (v0.43)
Add a new `dispatch_error_module` option to the subxt macro and CodegenBuilder that allows chains with rebranded runtime modules to specify their own path for the DispatchError type. By default, subxt generates: pub type DispatchError = runtime_types::sp_runtime::DispatchError; Chains like Kurdistan SDK (Pezkuwi) that rebrand sp_runtime to pezsp_runtime can now specify: dispatch_error_module = "pezsp_runtime" This generates: pub type DispatchError = runtime_types::pezsp_runtime::DispatchError; Changes: - codegen/src/lib.rs: Add dispatch_error_module field to CodegenBuilder - codegen/src/api/mod.rs: Pass dispatch_error_module to generate_runtime - codegen/src/api/calls.rs: Use configurable module path for DispatchError - macro/src/lib.rs: Add dispatch_error_module attribute parsing Based on v0.43.0 for API compatibility with Kurdistan SDK.
This commit is contained in:
@@ -56,6 +56,11 @@ struct RuntimeMetadataArgs {
|
||||
no_default_substitutions: bool,
|
||||
#[darling(default)]
|
||||
unstable_metadata: darling::util::Flag,
|
||||
/// The module path for DispatchError (default: "sp_runtime").
|
||||
/// Chains with rebranded runtime modules can use this to specify their path,
|
||||
/// e.g., "pezsp_runtime" for Kurdistan SDK.
|
||||
#[darling(default)]
|
||||
dispatch_error_module: Option<String>,
|
||||
#[cfg(feature = "runtime-wasm-path")]
|
||||
#[darling(default)]
|
||||
runtime_path: Option<String>,
|
||||
@@ -170,6 +175,11 @@ fn subxt_inner(args: TokenStream, item_mod: syn::ItemMod) -> Result<TokenStream,
|
||||
codegen.set_type_substitute(sub.path, sub.with);
|
||||
}
|
||||
|
||||
// Set the dispatch error module path if provided:
|
||||
if let Some(dispatch_error_module) = args.dispatch_error_module {
|
||||
codegen.set_dispatch_error_module(dispatch_error_module);
|
||||
}
|
||||
|
||||
let code = codegen
|
||||
.generate(metadata)
|
||||
.map_err(|e| e.into_compile_error())?;
|
||||
|
||||
Reference in New Issue
Block a user