mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 19:51:05 +00:00
[Deprecation] Remove the deprecated Store trait (#3532)
# Description *Removes the deprecated `trait Store` feature from the code base* Fixes #222 --------- Co-authored-by: Dónal Murray <donalm@seadanda.dev>
This commit is contained in:
@@ -858,16 +858,6 @@ pub fn disable_frame_system_supertrait_check(_: TokenStream, _: TokenStream) ->
|
||||
pallet_macro_stub()
|
||||
}
|
||||
|
||||
///
|
||||
/// ---
|
||||
///
|
||||
/// Rust-Analyzer Users: Documentation for this macro can be found at
|
||||
/// `frame_support::pallet_macros::generate_store`.
|
||||
#[proc_macro_attribute]
|
||||
pub fn generate_store(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
pallet_macro_stub()
|
||||
}
|
||||
|
||||
///
|
||||
/// ---
|
||||
///
|
||||
|
||||
@@ -31,7 +31,6 @@ mod instances;
|
||||
mod origin;
|
||||
mod pallet_struct;
|
||||
mod storage;
|
||||
mod store_trait;
|
||||
mod tasks;
|
||||
mod tt_default_parts;
|
||||
mod type_value;
|
||||
@@ -68,7 +67,6 @@ pub fn expand(mut def: Def) -> proc_macro2::TokenStream {
|
||||
let storages = storage::expand_storages(&mut def);
|
||||
let inherents = inherent::expand_inherents(&mut def);
|
||||
let instances = instances::expand_instances(&mut def);
|
||||
let store_trait = store_trait::expand_store_trait(&mut def);
|
||||
let hooks = hooks::expand_hooks(&mut def);
|
||||
let genesis_build = genesis_build::expand_genesis_build(&mut def);
|
||||
let genesis_config = genesis_config::expand_genesis_config(&mut def);
|
||||
@@ -110,7 +108,6 @@ storage item. Otherwise, all storage items are listed among [*Type Definitions*]
|
||||
#storages
|
||||
#inherents
|
||||
#instances
|
||||
#store_trait
|
||||
#hooks
|
||||
#genesis_build
|
||||
#genesis_config
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
// This file is part of Substrate.
|
||||
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
use crate::pallet::Def;
|
||||
use syn::spanned::Spanned;
|
||||
|
||||
/// If attribute `#[pallet::generate_store(..)]` is defined then:
|
||||
/// * generate Store trait with all storages,
|
||||
/// * implement Store trait for Pallet.
|
||||
pub fn expand_store_trait(def: &mut Def) -> proc_macro2::TokenStream {
|
||||
let (trait_vis, trait_store, attribute_span) =
|
||||
if let Some(store) = &def.pallet_struct.store { store } else { return Default::default() };
|
||||
|
||||
let type_impl_gen = &def.type_impl_generics(trait_store.span());
|
||||
let type_use_gen = &def.type_use_generics(trait_store.span());
|
||||
let pallet_ident = &def.pallet_struct.pallet;
|
||||
|
||||
let mut where_clauses = vec![&def.config.where_clause];
|
||||
where_clauses.extend(def.storages.iter().map(|storage| &storage.where_clause));
|
||||
let completed_where_clause = super::merge_where_clauses(&where_clauses);
|
||||
|
||||
let storage_names = &def.storages.iter().map(|storage| &storage.ident).collect::<Vec<_>>();
|
||||
let storage_cfg_attrs =
|
||||
&def.storages.iter().map(|storage| &storage.cfg_attrs).collect::<Vec<_>>();
|
||||
let warnig_struct_name = syn::Ident::new("Store", *attribute_span);
|
||||
let warning: syn::ItemStruct = syn::parse_quote!(
|
||||
#[deprecated(note = r"
|
||||
Use of `#[pallet::generate_store(pub(super) trait Store)]` will be removed after July 2023.
|
||||
Check https://github.com/paritytech/substrate/pull/13535 for more details.")]
|
||||
struct #warnig_struct_name;
|
||||
);
|
||||
|
||||
quote::quote_spanned!(trait_store.span() =>
|
||||
const _:() = {
|
||||
#warning
|
||||
const _: Option<#warnig_struct_name> = None;
|
||||
};
|
||||
#trait_vis trait #trait_store {
|
||||
#(
|
||||
#(#storage_cfg_attrs)*
|
||||
type #storage_names;
|
||||
)*
|
||||
}
|
||||
impl<#type_impl_gen> #trait_store for #pallet_ident<#type_use_gen>
|
||||
#completed_where_clause
|
||||
{
|
||||
#(
|
||||
#(#storage_cfg_attrs)*
|
||||
type #storage_names = #storage_names<#type_use_gen>;
|
||||
)*
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -558,8 +558,6 @@ mod keyword {
|
||||
syn::custom_keyword!(validate_unsigned);
|
||||
syn::custom_keyword!(type_value);
|
||||
syn::custom_keyword!(pallet);
|
||||
syn::custom_keyword!(generate_store);
|
||||
syn::custom_keyword!(Store);
|
||||
syn::custom_keyword!(extra_constants);
|
||||
syn::custom_keyword!(composite_enum);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,8 @@ use syn::spanned::Spanned;
|
||||
mod keyword {
|
||||
syn::custom_keyword!(pallet);
|
||||
syn::custom_keyword!(Pallet);
|
||||
syn::custom_keyword!(generate_store);
|
||||
syn::custom_keyword!(without_storage_info);
|
||||
syn::custom_keyword!(storage_version);
|
||||
syn::custom_keyword!(Store);
|
||||
}
|
||||
|
||||
/// Definition of the pallet pallet.
|
||||
@@ -37,8 +35,6 @@ pub struct PalletStructDef {
|
||||
pub instances: Vec<helper::InstanceUsage>,
|
||||
/// The keyword Pallet used (contains span).
|
||||
pub pallet: keyword::Pallet,
|
||||
/// Whether the trait `Store` must be generated.
|
||||
pub store: Option<(syn::Visibility, keyword::Store, proc_macro2::Span)>,
|
||||
/// The span of the pallet::pallet attribute.
|
||||
pub attr_span: proc_macro2::Span,
|
||||
/// Whether to specify the storages max encoded len when implementing `StorageInfoTrait`.
|
||||
@@ -49,11 +45,9 @@ pub struct PalletStructDef {
|
||||
}
|
||||
|
||||
/// Parse for one variant of:
|
||||
/// * `#[pallet::generate_store($vis trait Store)]`
|
||||
/// * `#[pallet::without_storage_info]`
|
||||
/// * `#[pallet::storage_version(STORAGE_VERSION)]`
|
||||
pub enum PalletStructAttr {
|
||||
GenerateStore { span: proc_macro2::Span, vis: syn::Visibility, keyword: keyword::Store },
|
||||
WithoutStorageInfoTrait(proc_macro2::Span),
|
||||
StorageVersion { storage_version: syn::Path, span: proc_macro2::Span },
|
||||
}
|
||||
@@ -61,9 +55,7 @@ pub enum PalletStructAttr {
|
||||
impl PalletStructAttr {
|
||||
fn span(&self) -> proc_macro2::Span {
|
||||
match self {
|
||||
Self::GenerateStore { span, .. } |
|
||||
Self::WithoutStorageInfoTrait(span) |
|
||||
Self::StorageVersion { span, .. } => *span,
|
||||
Self::WithoutStorageInfoTrait(span) | Self::StorageVersion { span, .. } => *span,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -77,16 +69,7 @@ impl syn::parse::Parse for PalletStructAttr {
|
||||
content.parse::<syn::Token![::]>()?;
|
||||
|
||||
let lookahead = content.lookahead1();
|
||||
if lookahead.peek(keyword::generate_store) {
|
||||
content.parse::<keyword::generate_store>()?;
|
||||
let generate_content;
|
||||
syn::parenthesized!(generate_content in content);
|
||||
let vis = generate_content.parse::<syn::Visibility>()?;
|
||||
generate_content.parse::<syn::Token![trait]>()?;
|
||||
let keyword = generate_content.parse::<keyword::Store>()?;
|
||||
let span = content.span();
|
||||
Ok(Self::GenerateStore { vis, keyword, span })
|
||||
} else if lookahead.peek(keyword::without_storage_info) {
|
||||
if lookahead.peek(keyword::without_storage_info) {
|
||||
let span = content.parse::<keyword::without_storage_info>()?.span();
|
||||
Ok(Self::WithoutStorageInfoTrait(span))
|
||||
} else if lookahead.peek(keyword::storage_version) {
|
||||
@@ -116,16 +99,12 @@ impl PalletStructDef {
|
||||
return Err(syn::Error::new(item.span(), msg))
|
||||
};
|
||||
|
||||
let mut store = None;
|
||||
let mut without_storage_info = None;
|
||||
let mut storage_version_found = None;
|
||||
|
||||
let struct_attrs: Vec<PalletStructAttr> = helper::take_item_pallet_attrs(&mut item.attrs)?;
|
||||
for attr in struct_attrs {
|
||||
match attr {
|
||||
PalletStructAttr::GenerateStore { vis, keyword, span } if store.is_none() => {
|
||||
store = Some((vis, keyword, span));
|
||||
},
|
||||
PalletStructAttr::WithoutStorageInfoTrait(span)
|
||||
if without_storage_info.is_none() =>
|
||||
{
|
||||
@@ -162,7 +141,6 @@ impl PalletStructDef {
|
||||
index,
|
||||
instances,
|
||||
pallet,
|
||||
store,
|
||||
attr_span,
|
||||
without_storage_info,
|
||||
storage_version: storage_version_found,
|
||||
|
||||
Reference in New Issue
Block a user