3

I have a StorageValue defined as follows

    #[pallet::storage]
    #[pallet::getter(fn reg_students)]
    pub type RegStudents<T: Config> =
        StorageValue<_, BoundedVec<StudentId, T::MaxStudents>, ValueQuery>;

and the types are defined as follows

#[pallet::constant]
type MaxStudents: Get<u16>;

pub type StudentId = u32;

I am getting the following error compiling

62  | pub trait StorageValue<T: FullCodec> {
    |                           ^^^^^^^^^ required by this bound in `frame_support::StorageValue::get`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
    |
103 |     #[pallet::storage where sp_runtime::BoundedVec<u32, <T as pallet::Config>::MaxStudents>: Decode]

StorageValue<_, BoundedVec<StudentId, T::MaxStudents>, ValueQuery>;
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Decode` is not implemented for `sp_runtime::BoundedVec<u32, <T as pallet::Config>::MaxStudents>`

1 Answer 1

3

Please check the impl.

https://paritytech.github.io/substrate/master/src/sp_core/bounded/bounded_vec.rs.html#45

It requires Get<u32>.

Try:

#[pallet::constant]
type MaxStudents: Get<u32>;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.