I'm trying to create a pallet that handles extrinsic and also runtime-api for the RPC endpoints. Since I plan to query storage items with RPC, I've created primitives for my pallet to use within my pallet and RPC.
I've taken a look at the Beefy Pallet and its primitives. I've implemented the code for my use case but got a bunch of errors about encodes and decodes.
I see that Beefy doesn't implement the traits specified in the error messages. Do I have to implement those? What causes these errors?
// ./profile/common/src/lib.rs
#[derive(Decode, Encode, Debug, PartialEq, Clone, TypeInfo)]
pub struct About<Hash> {
pub option_one: Option<Vec<u8>>,
pub option_two: Hash,
}
// ./profile/src/lib.rs
use pallet_profile_primitives::About;
...
#[pallet::storage]
#[pallet::getter(fn validator_set_id)]
pub(super) type ValidatorSetId<T: Config> = StorageValue<_, About<T::Hash>, OptionQuery>;
error[E0277]: the trait bound `About: WrapperTypeDecode` is not satisfied
--> pallets/estatetial/profile/src/lib.rs:27:12
|
27 | #[pallet::pallet]
| ^^^^^^ the trait `WrapperTypeDecode` is not implemented for `About`
|
= note: required because of the requirements on the impl of `Decode` for `About`
= note: required because of the requirements on the impl of `FullCodec` for `About`
= note: required because of the requirements on the impl of `PartialStorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageValidatorSetId<T>, About<<T as frame_system::Config>::Hash>>`
error[E0277]: the trait bound `About: EncodeLike` is not satisfied
--> pallets/estatetial/profile/src/lib.rs:27:12
|
27 | #[pallet::pallet]
| ^^^^^^ the trait `EncodeLike` is not implemented for `About`
|
= note: required because of the requirements on the impl of `FullEncode` for `About`
= note: required because of the requirements on the impl of `FullCodec` for `About`
= note: required because of the requirements on the impl of `PartialStorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageValidatorSetId<T>, About<<T as frame_system::Config>::Hash>>`
error[E0277]: the trait bound `About: WrapperTypeEncode` is not satisfied
--> pallets/estatetial/profile/src/lib.rs:27:12
|
27 | #[pallet::pallet]
| ^^^^^^ the trait `WrapperTypeEncode` is not implemented for `About`
|
= note: required because of the requirements on the impl of `Encode` for `About`
= note: required because of the requirements on the impl of `FullEncode` for `About`
= note: required because of the requirements on the impl of `FullCodec` for `About`
= note: required because of the requirements on the impl of `PartialStorageInfoTrait` for `frame_support::pallet_prelude::StorageValue<_GeneratedPrefixForStorageValidatorSetId<T>, About<<T as frame_system::Config>::Hash>>`
devhub/latest
tag. Yes, they are all the same. And, I just found a solution. Will post it here soon. Thanks for the comment.Bounded Vec
is the way to go, as it's required for parachains to have bounded storage items (baseVec
is unbounded) - this then should not be annotated as such. paritytech.github.io/substrate/master/frame_support/storage/…MaxEncodedLen
is required forVec
. Also, usingWeakBoundedVec
might be a workaround in my opinion.