Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
29 changes: 29 additions & 0 deletions substrate/frame/support/procedural/examples/section/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use frame_support::pallet_macros::{import_section, pallet_section};
Comment thread
eagr marked this conversation as resolved.
Outdated

#[pallet_section]
pub mod storage {
#[pallet::storage]
pub type TotalIssuance1<T> = StorageValue<_, u64, ValueQuery>;
#[pallet::storage]
pub type TotalIssuance2<T> = StorageValue<_, u64, ValueQuery>;
}

#[import_section(storage)]
#[frame_support::pallet]
pub mod pallet {
use frame_support::pallet_prelude::*;

const STORAGE_VERSION: StorageVersion = StorageVersion::new(7);

#[pallet::pallet]
#[pallet::storage_version(STORAGE_VERSION)]
pub struct Pallet<T>(_);

#[pallet::config]
pub trait Config: frame_system::Config {
}
}

fn main() {
println!("Pallet section storage works!");
}
23 changes: 13 additions & 10 deletions substrate/frame/support/procedural/src/pallet/expand/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,17 +425,20 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
Ok(deprecation) => deprecation,
Err(e) => return e.into_compile_error(),
};
// FIXME eagr just use quote::quote!() instead?
Comment thread
eagr marked this conversation as resolved.
Outdated
entries_builder.push(quote::quote_spanned!(storage.attr_span =>
#(#cfg_attrs)*
{
<#full_ident as #frame_support::storage::StorageEntryMetadataBuilder>::build_metadata(
#deprecation,
#frame_support::__private::vec![
#( #docs, )*
],
&mut entries,
);
}
(|entries: &mut #frame_support::__private::Vec<_>| {
{
<#full_ident as #frame_support::storage::StorageEntryMetadataBuilder>::build_metadata(
#deprecation,
#frame_support::__private::vec![
#( #docs, )*
],
entries,
);
}
})
))
}

Expand Down Expand Up @@ -911,7 +914,7 @@ pub fn expand_storages(def: &mut Def) -> proc_macro2::TokenStream {
entries: {
#[allow(unused_mut)]
let mut entries = #frame_support::__private::vec![];
#( #entries_builder )*
#( #entries_builder(&mut entries); )*
entries
},
}
Expand Down