Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Clone for the generated RuntimeApi #544

Merged
merged 4 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions codegen/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,9 @@ impl RuntimeGenerator {
quote! {
#[allow(dead_code, unused_imports, non_camel_case_types)]
pub mod #mod_ident {
// Ensure the `RuntimeApi` can be cloned without implying bounds over
// generic parameters.
use ::subxt::Derivative;
// Make it easy to access the root via `root_mod` at different levels:
use super::#mod_ident as root_mod;
// Identify the pallets composing the static metadata by name.
Expand All @@ -291,6 +294,8 @@ impl RuntimeGenerator {
// Impl HasModuleError on DispatchError so we can pluck out module error details.
#has_module_error_impl

#[derive(Derivative)]
#[derivative(Clone(bound = ""))]
pub struct RuntimeApi<T: ::subxt::Config, X> {
pub client: ::subxt::Client<T>,
marker: ::core::marker::PhantomData<X>,
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ use codec::{
Encode,
};
use core::fmt::Debug;
use derivative::Derivative;
pub use derivative::Derivative;
lexnv marked this conversation as resolved.
Show resolved Hide resolved

mod client;
mod config;
Expand Down