cargo +nightly fmt

This commit is contained in:
Tadeo hepperle
2023-05-10 14:26:10 +02:00
parent 213bc4c47a
commit a3419a6f44
94 changed files with 326 additions and 259 deletions
+6 -5
View File
@@ -2,16 +2,17 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15};
use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_info::form::PortableForm;
use super::CodegenError;
use crate::{
types::{CompositeDefFields, TypeGenerator},
CratePath,
};
use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15};
use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_info::form::PortableForm;
/// Generate calls from the provided pallet's metadata. Each call returns a `StaticTxPayload`
/// that can be passed to the subxt client to submit/sign/encode.
+1 -1
View File
@@ -2,7 +2,6 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{types::TypeGenerator, CratePath};
use frame_metadata::v15::{PalletMetadata, RuntimeMetadataV15};
use heck::ToSnakeCase as _;
use proc_macro2::TokenStream as TokenStream2;
@@ -10,6 +9,7 @@ use quote::{format_ident, quote};
use scale_info::form::PortableForm;
use super::CodegenError;
use crate::{types::TypeGenerator, CratePath};
/// Generate constants from the provided pallet's metadata.
///
+1 -2
View File
@@ -7,9 +7,8 @@ use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use scale_info::form::PortableForm;
use crate::types::TypeGenerator;
use super::CodegenError;
use crate::types::TypeGenerator;
/// Generate error type alias from the provided pallet metadata.
pub fn generate_error_type_alias(
+1 -1
View File
@@ -2,13 +2,13 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{types::TypeGenerator, CratePath};
use frame_metadata::v15::PalletMetadata;
use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use scale_info::form::PortableForm;
use super::CodegenError;
use crate::{types::TypeGenerator, CratePath};
/// Generate events from the provided pallet metadata.
///
+9 -9
View File
@@ -11,24 +11,24 @@ mod events;
mod runtime_apis;
mod storage;
use frame_metadata::v15::RuntimeMetadataV15;
use std::{fs, io::Read, path, string::ToString};
use codec::Decode;
use frame_metadata::{v15::RuntimeMetadataV15, RuntimeMetadata, RuntimeMetadataPrefixed};
use heck::ToSnakeCase as _;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use subxt_metadata::{get_metadata_per_pallet_hash, metadata_v14_to_latest};
use syn::parse_quote;
use super::DerivesRegistry;
use crate::error::CodegenError;
use crate::{
error::CodegenError,
ir,
types::{CompositeDef, CompositeDefFields, TypeGenerator, TypeSubstitutes},
utils::{fetch_metadata_bytes_blocking, MetadataVersion, Uri},
CratePath,
};
use codec::Decode;
use frame_metadata::{RuntimeMetadata, RuntimeMetadataPrefixed};
use heck::ToSnakeCase as _;
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use std::{fs, io::Read, path, string::ToString};
use syn::parse_quote;
/// Generates the API for interacting with a Substrate runtime.
///
+3 -4
View File
@@ -2,15 +2,14 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{types::TypeGenerator, CodegenError, CratePath};
use frame_metadata::v15::{RuntimeApiMetadata, RuntimeMetadataV15};
use heck::ToSnakeCase as _;
use heck::ToUpperCamelCase as _;
use heck::{ToSnakeCase as _, ToUpperCamelCase as _};
use proc_macro2::TokenStream as TokenStream2;
use quote::{format_ident, quote};
use scale_info::form::PortableForm;
use crate::{types::TypeGenerator, CodegenError, CratePath};
/// Generates runtime functions for the given API metadata.
fn generate_runtime_api(
metadata: &RuntimeMetadataV15,
+1 -1
View File
@@ -2,7 +2,6 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{types::TypeGenerator, CratePath};
use frame_metadata::v15::{
PalletMetadata, RuntimeMetadataV15, StorageEntryMetadata, StorageEntryModifier,
StorageEntryType,
@@ -13,6 +12,7 @@ use quote::{format_ident, quote};
use scale_info::{form::PortableForm, TypeDef};
use super::CodegenError;
use crate::{types::TypeGenerator, CratePath};
/// Generate functions which create storage addresses from the provided pallet's metadata.
/// These addresses can be used to access and iterate over storage values.
+2 -1
View File
@@ -2,9 +2,10 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::error::CodegenError;
use syn::token;
use crate::error::CodegenError;
#[derive(Debug, PartialEq, Eq)]
pub struct ItemMod {
vis: syn::Visibility,
+3 -3
View File
@@ -2,13 +2,13 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::error::CodegenError;
use super::{CratePath, Derives, Field, TypeDefParameters, TypeGenerator, TypeParameter, TypePath};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use scale_info::{form::PortableForm, Type, TypeDef, TypeDefPrimitive};
use super::{CratePath, Derives, Field, TypeDefParameters, TypeGenerator, TypeParameter, TypePath};
use crate::error::CodegenError;
/// Representation of a type which consists of a set of fields. Used to generate Rust code for
/// either a standalone `struct` definition, or an `enum` variant.
///
+3 -2
View File
@@ -2,10 +2,11 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::CratePath;
use std::collections::{HashMap, HashSet};
use syn::{parse_quote, Path};
use std::collections::{HashMap, HashSet};
use crate::CratePath;
/// A struct containing the derives that we'll be applying to types;
/// a combination of some common derives for all types, plus type
+3 -3
View File
@@ -11,12 +11,11 @@ mod type_def;
mod type_def_params;
mod type_path;
use std::collections::BTreeMap;
use proc_macro2::{Ident, Span, TokenStream};
use quote::{quote, ToTokens};
use scale_info::{form::PortableForm, PortableRegistry, Type, TypeDef};
use std::collections::BTreeMap;
use crate::error::CodegenError;
pub use self::{
composite_def::{CompositeDef, CompositeDefFieldType, CompositeDefFields},
@@ -26,6 +25,7 @@ pub use self::{
type_def_params::TypeDefParameters,
type_path::{TypeParameter, TypePath, TypePathType},
};
use crate::error::CodegenError;
pub type Field = scale_info::Field<PortableForm>;
+2 -1
View File
@@ -2,11 +2,12 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::{error::TypeSubstitutionError, CratePath};
use std::{borrow::Borrow, collections::HashMap};
use syn::{parse_quote, spanned::Spanned as _};
use super::{TypePath, TypePathType};
use crate::{error::TypeSubstitutionError, CratePath};
/// A map of type substitutes. We match on the paths to generated types in order
/// to figure out when to swap said type with some provided substitute.
+2 -1
View File
@@ -2,11 +2,12 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use super::*;
use pretty_assertions::assert_eq;
use scale_info::{meta_type, scale, Registry, TypeInfo};
use syn::parse_quote;
use super::*;
const MOD_PATH: &[&str] = &["subxt_codegen", "types", "tests"];
fn get_mod<'a>(module: &'a Module, path_segs: &[&'static str]) -> Option<&'a Module> {
+5 -5
View File
@@ -2,16 +2,16 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::error::CodegenError;
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use scale_info::{form::PortableForm, Type, TypeDef};
use syn::parse_quote;
use super::{
CompositeDef, CompositeDefFields, CratePath, Derives, TypeDefParameters, TypeGenerator,
TypeParameter,
};
use proc_macro2::TokenStream;
use quote::{format_ident, quote};
use scale_info::{form::PortableForm, Type, TypeDef};
use syn::parse_quote;
use crate::error::CodegenError;
/// Generates a Rust `struct` or `enum` definition based on the supplied [`scale-info::Type`].
///
+4 -2
View File
@@ -2,10 +2,12 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use std::collections::BTreeSet;
use quote::quote;
use super::TypeParameter;
use crate::types::CompositeDefFieldType;
use quote::quote;
use std::collections::BTreeSet;
/// Represents the set of generic type parameters for generating a type definition e.g. the `T` in
/// `Foo<T>`.
+3 -2
View File
@@ -2,14 +2,15 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::CratePath;
use std::collections::BTreeSet;
use proc_macro2::{Ident, TokenStream};
use quote::format_ident;
use scale_info::{form::PortableForm, Path, TypeDefPrimitive};
use std::collections::BTreeSet;
use syn::parse_quote;
use crate::CratePath;
/// An opaque struct representing a type path. The main usage of this is
/// to spit out as tokens in some `quote!{ ... }` macro; the inner structure
/// should be unimportant.
+4 -2
View File
@@ -2,7 +2,8 @@
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
// see LICENSE for license details.
use crate::error::FetchMetadataError;
use std::time::Duration;
use codec::{Decode, Encode};
use jsonrpsee::{
async_client::ClientBuilder,
@@ -11,7 +12,8 @@ use jsonrpsee::{
http_client::HttpClientBuilder,
rpc_params,
};
use std::time::Duration;
use crate::error::FetchMetadataError;
/// The metadata version that is fetched from the node.
#[derive(Default, Debug, Clone, Copy)]
+1 -2
View File
@@ -7,9 +7,8 @@
mod fetch_metadata;
// easy access to this type needed for fetching metadata:
pub use jsonrpsee::client_transport::ws::Uri;
pub use fetch_metadata::{
fetch_metadata_bytes, fetch_metadata_bytes_blocking, fetch_metadata_hex,
fetch_metadata_hex_blocking, MetadataVersion,
};
pub use jsonrpsee::client_transport::ws::Uri;