Allow specifying the subxt crate path for generated code (#664)

* Allow specifying the `subxt` crate path for generated code

* Make `clippy` happy

* Add documentation

* Improve optics

* Remove custom crate path test

* Implement comments

* Update comment

* Make `crate_path` property instead of argument

* Remove unnecessary derives

* Remove `Default` impls in favor of explicit constructors

* Remove unnecessary `into`

* Update codegen/src/types/mod.rs

Co-authored-by: Andrew Jones <ascjones@gmail.com>

Co-authored-by: Andrew Jones <ascjones@gmail.com>
This commit is contained in:
Michael Müller
2022-09-27 12:41:36 +02:00
committed by GitHub
parent 75e383dfcf
commit f115ff975c
15 changed files with 342 additions and 146 deletions
+4 -3
View File
@@ -21,7 +21,7 @@
//! use std::fs;
//! use codec::Decode;
//! use frame_metadata::RuntimeMetadataPrefixed;
//! use subxt_codegen::DerivesRegistry;
//! use subxt_codegen::{CratePath, DerivesRegistry};
//!
//! let encoded = fs::read("../artifacts/polkadot_metadata.scale").unwrap();
//!
@@ -32,10 +32,10 @@
//! pub mod api {}
//! );
//! // Default module derivatives.
//! let mut derives = DerivesRegistry::default();
//! let mut derives = DerivesRegistry::new(&CratePath::default());
//! // Generate the Runtime API.
//! let generator = subxt_codegen::RuntimeGenerator::new(metadata);
//! let runtime_api = generator.generate_runtime(item_mod, derives);
//! let runtime_api = generator.generate_runtime(item_mod, derives, CratePath::default());
//! println!("{}", runtime_api);
//! ```
@@ -51,6 +51,7 @@ pub use self::{
RuntimeGenerator,
},
types::{
CratePath,
Derives,
DerivesRegistry,
Module,