Add an INDEX to the Instance trait (#8555)

* Add an index to the Instance trait

* Update frame/support/procedural/src/storage/instance_trait.rs
This commit is contained in:
Shawn Tabrizi
2021-04-07 14:58:23 +02:00
committed by GitHub
parent 1cb3590f49
commit d8c1a1d12b
5 changed files with 23 additions and 8 deletions
@@ -17,14 +17,15 @@
use proc_macro2::Span;
use crate::pallet::Def;
use crate::NUMBER_OF_INSTANCE;
/// * Provide inherent instance to be used by construct_runtime
/// * Provide Instance0 .. Instance16 for instantiable pallet
/// * Provide Instance1 ..= Instance16 for instantiable pallet
pub fn expand_instances(def: &mut Def) -> proc_macro2::TokenStream {
let frame_support = &def.frame_support;
let inherent_ident = syn::Ident::new(crate::INHERENT_INSTANCE_NAME, Span::call_site());
let instances = if def.config.has_instance {
(0..16).map(|i| syn::Ident::new(&format!("Instance{}", i), Span::call_site())).collect()
(1..=NUMBER_OF_INSTANCE).map(|i| syn::Ident::new(&format!("Instance{}", i), Span::call_site())).collect()
} else {
vec![]
};