Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 7 additions & 2 deletions crates/ink/ir/src/ir/storage_item/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,13 @@ impl StorageItem {
}

/// Returns the generics of the storage.
pub fn generics(&self) -> &syn::Generics {
&self.ast.generics
pub fn generics(&self) -> TokenStream2 {
let types = self.ast.generics.clone();
// `where_closure` is not included into `types`, so add it manually.
let (_, _, where_closure) = self.ast.generics.split_for_impl();
quote! {
#types #where_closure
}
}

/// Returns data of the storage.
Expand Down
14 changes: 12 additions & 2 deletions crates/ink/macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
/// feature = "std",
/// derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout)
/// )]
/// #[derive(Default, Debug)]
/// struct Packed {
/// s1: u128,
/// s2: Vec<u128>,
Expand All @@ -710,6 +711,7 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
/// feature = "std",
/// derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout)
/// )]
/// #[derive(Default, Debug)]
/// struct PackedGeneric<T: ink::storage::traits::Packed> {
/// s1: (u128, bool),
/// s2: Vec<T>,
Expand All @@ -718,6 +720,7 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
///
/// // Example of how to define the non-packed type.
/// #[ink::storage_item]
/// #[derive(Default, Debug)]
/// struct NonPacked {
/// s1: Mapping<u32, u128>,
/// s2: Lazy<u128>,
Expand All @@ -730,7 +733,12 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
/// feature = "std",
/// derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout)
/// )]
/// struct NonPackedGeneric<T: ink::storage::traits::Packed> {
/// #[derive(Default, Debug)]
/// struct NonPackedGeneric<T>
/// where
/// T: Default + core::fmt::Debug,
/// T: ink::storage::traits::Packed,
/// {
/// s1: u32,
/// s2: T,
/// s3: Mapping<u128, T>,
Expand All @@ -742,6 +750,7 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
/// feature = "std",
/// derive(scale_info::TypeInfo, ink::storage::traits::StorageLayout)
/// )]
/// #[derive(Default, Debug)]
/// struct PackedComplex {
/// s1: u128,
/// s2: Vec<u128>,
Expand All @@ -750,6 +759,7 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
///
/// // Example of how to define a complex non-packed type.
/// #[ink::storage_item]
/// #[derive(Default, Debug)]
/// struct NonPackedComplex<KEY: StorageKey> {
/// s1: (String, u128, Packed),
/// s2: Mapping<u128, u128>,
Expand Down Expand Up @@ -779,8 +789,8 @@ pub fn trait_definition(attr: TokenStream, item: TokenStream) -> TokenStream {
/// use ink::storage::traits::{
/// StorableHint,
/// StorageKey,
/// Storable,
/// };
/// use ink::storage::traits::Storable;
///
/// #[ink::storage_item(derive = false)]
/// #[derive(StorableHint, Storable, StorageKey)]
Expand Down
2 changes: 1 addition & 1 deletion examples/erc1155/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ mod erc1155 {
self.env().emit_event(TransferSingle {
operator: Some(caller),
from: Some(from),
to: Some(from),
to: Some(to),
token_id,
value,
});
Expand Down