mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 10:48:04 +00:00
12e343449e
* minor api changes * parsing instead of format_ident! * fix self issue * expose types on typegen * web wasm support via feature flag * fmt and clippy * small adjustments * remove exposing of types() in type generator * adjust compile error * remove little any flag * Need access to the type registry from the typegen again * Bump proc-macro2 from 1.0.66 to 1.0.67 (#1164) Bumps [proc-macro2](https://github.com/dtolnay/proc-macro2) from 1.0.66 to 1.0.67. - [Release notes](https://github.com/dtolnay/proc-macro2/releases) - [Commits](https://github.com/dtolnay/proc-macro2/compare/1.0.66...1.0.67) --- updated-dependencies: - dependency-name: proc-macro2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump serde_json from 1.0.106 to 1.0.107 (#1166) Bumps [serde_json](https://github.com/serde-rs/json) from 1.0.106 to 1.0.107. - [Release notes](https://github.com/serde-rs/json/releases) - [Commits](https://github.com/serde-rs/json/compare/v1.0.106...v1.0.107) --- updated-dependencies: - dependency-name: serde_json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump trybuild from 1.0.84 to 1.0.85 (#1167) Bumps [trybuild](https://github.com/dtolnay/trybuild) from 1.0.84 to 1.0.85. - [Release notes](https://github.com/dtolnay/trybuild/releases) - [Commits](https://github.com/dtolnay/trybuild/compare/1.0.84...1.0.85) --- updated-dependencies: - dependency-name: trybuild dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump Swatinem/rust-cache from 2.6.2 to 2.7.0 (#1168) Bumps [Swatinem/rust-cache](https://github.com/swatinem/rust-cache) from 2.6.2 to 2.7.0. - [Release notes](https://github.com/swatinem/rust-cache/releases) - [Changelog](https://github.com/Swatinem/rust-cache/blob/master/CHANGELOG.md) - [Commits](https://github.com/swatinem/rust-cache/compare/e207df5d269b42b69c8bc5101da26f7d31feddb4...a95ba195448af2da9b00fb742d14ffaaf3c21f43) --- updated-dependencies: - dependency-name: Swatinem/rust-cache dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jsonrpsee from 0.20.0 to 0.20.1 (#1165) Bumps [jsonrpsee](https://github.com/paritytech/jsonrpsee) from 0.20.0 to 0.20.1. - [Release notes](https://github.com/paritytech/jsonrpsee/releases) - [Changelog](https://github.com/paritytech/jsonrpsee/blob/v0.20.1/CHANGELOG.md) - [Commits](https://github.com/paritytech/jsonrpsee/compare/v0.20.0...v0.20.1) --- updated-dependencies: - dependency-name: jsonrpsee dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump clap from 4.4.2 to 4.4.3 (#1163) Bumps [clap](https://github.com/clap-rs/clap) from 4.4.2 to 4.4.3. - [Release notes](https://github.com/clap-rs/clap/releases) - [Changelog](https://github.com/clap-rs/clap/blob/master/CHANGELOG.md) - [Commits](https://github.com/clap-rs/clap/compare/v4.4.2...v4.4.3) --- updated-dependencies: - dependency-name: clap dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix double quote import introduced by merge * clippy * put ensure_unique_types on metadata, revert toml changes * fmt * solve frame_metadata import * tidy fetch-metadata and non_exhaustive on errors * remove the getrandom thing * fix toml autoformatting --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Wilson <james@jsdw.me>
67 lines
2.3 KiB
Rust
67 lines
2.3 KiB
Rust
// Copyright 2019-2023 Parity Technologies (UK) Ltd.
|
|
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
|
// see LICENSE for license details.
|
|
|
|
//! Library to generate an API for a Substrate runtime from its metadata.
|
|
//!
|
|
//! ## Generated Structure
|
|
//!
|
|
//! The API generator logic:
|
|
//! - At the root there is the `item_mod` provided (ie `pub mod api {}`)
|
|
//! - Pallets are represented by a child module (ie `pub mod PalletName {}`) of the root
|
|
//! - Each pallet exposes as child modules (if applicable):
|
|
//! - Calls (`pub mod calls {}`)
|
|
//! - Events (`pub mod events {}`)
|
|
//! - Storage (`pub mod storage {}`)
|
|
//! - Constants (`pub mod constants {}`)
|
|
//!
|
|
//! ## Example
|
|
//!
|
|
//! ```no_run
|
|
//! use std::fs;
|
|
//! use codec::Decode;
|
|
//! use subxt_metadata::Metadata;
|
|
//! use subxt_codegen::{CratePath, DerivesRegistry, TypeSubstitutes};
|
|
//!
|
|
//! let encoded = fs::read("../artifacts/polkadot_metadata_full.scale").unwrap();
|
|
//!
|
|
//! // Runtime metadata obtained from a node.
|
|
//! let metadata = Metadata::decode(&mut &*encoded).unwrap();
|
|
//! // Module under which the API is generated.
|
|
//! let item_mod = syn::parse_quote!(
|
|
//! pub mod api {}
|
|
//! );
|
|
//! // Default module derivatives.
|
|
//! let mut derives = DerivesRegistry::with_default_derives(&CratePath::default());
|
|
//! // Default type substitutes.
|
|
//! let substs = TypeSubstitutes::with_default_substitutes(&CratePath::default());
|
|
//! // Generate the Runtime API.
|
|
//! let generator = subxt_codegen::RuntimeGenerator::new(metadata);
|
|
//! // Include metadata documentation in the Runtime API.
|
|
//! let generate_docs = true;
|
|
//! let runtime_api = generator.generate_runtime(item_mod, derives, substs, CratePath::default(), generate_docs).unwrap();
|
|
//! println!("{}", runtime_api);
|
|
//! ```
|
|
|
|
#![deny(unused_crate_dependencies, missing_docs)]
|
|
|
|
mod api;
|
|
mod error;
|
|
mod ir;
|
|
mod types;
|
|
|
|
#[cfg(feature = "fetch-metadata")]
|
|
pub mod utils;
|
|
|
|
#[cfg(all(feature = "web", feature = "fetch-metadata"))]
|
|
compile_error!("subxt-codegen: the features 'web' and 'fetch_metadata' cannot be used together.");
|
|
|
|
pub use self::{
|
|
api::{GenerateRuntimeApi, RuntimeGenerator},
|
|
error::{CodegenError, TypeSubstitutionError},
|
|
types::{
|
|
CratePath, Derives, DerivesRegistry, Module, TypeDefGen, TypeDefParameters, TypeGenerator,
|
|
TypeSubstitutes,
|
|
},
|
|
};
|