版本:
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-10'
Version = '4.0.0-dev'
升级到最新的基板版本后,我得到错误:
the trait bound `types::DepartmentDetails: scale_info::TypeInfo` is not satisfied
这是我的存储空间:
#[pallet::storage]
#[pallet::getter(fn department_profile)]
pub type Department<T> = StorageMap<_, Blake2_128Concat, u128, DepartmentDetails>;
DepartmentDetails是一个结构体
#[derive(PartialEq, Eq, PartialOrd, Ord, Default, Clone, Encode, Decode, RuntimeDebug)]
pub struct DepartmentDetails {
pub name: Vec<u8>,
pub location: Vec<u8>,
pub details: Vec<u8>,
pub departmentid: u128,
}
版本:
git = 'https://github.com/paritytech/substrate.git'
tag = 'monthly-2021-10'
Version = '4.0.0-dev'
存储需要声明它的元数据。要做到这一点,它需要键和值类型来实现特性TypeInfo
: https://docs.rs/scale-info/1.0.0/scale_info/trait.TypeInfo.html
为了轻松实现它,您可以使用派生宏:TypeInfo
https://docs.rs/scale-info-derive/1.0.0/scale_info_derive/derive.TypeInfo.html
通常,您添加特性derive
到scale_info crate依赖,以便从scale_info访问此派生宏。然后你可以写:
#[derive(PartialEq, Eq, PartialOrd, Ord, Default, Clone, Encode, Decode, RuntimeDebug, scale_info::TypeInfo)]
pub struct DepartmentDetails {
pub name: Vec<u8>,
pub location: Vec<u8>,
pub details: Vec<u8>,
pub departmentid: u128,
}