pub struct Post<A> {
id:u8,
content:String,
tipAmount:u8,
author:A,
}
decl_storage! {
trait Store for Module<T: Trait> as PostModule {
Posts: map hasher(blake2_256) u8 => Post<T::AccountId>;
}
}
I'm getting below error
the trait _::_parity_scale_codec::EncodeLike is not implemented for Post<::AccountId>
How we can map primitive data type with struct in decl_storage! Macro
You have two problems. One is rather mild, the other more serious:
Encode
and Decode
from [parity-scale-codec
]. Include this in your crate (with the "derive" feature) and simply:#[derive(Encode, Decode)]
pub struct Post<A> {
id:u8,
content:String,
tipAmount:u8,
author:A,
}
Look at any other pallet in Parity's Frame library for examples. Note that most often (unless if your value is an Option
) your type must also provide a Default
, that you can again derive.