代码之家  ›  专栏  ›  技术社区  ›  not 0x12

错误检查包含StorageMap中组合键的_键

  •  0
  • not 0x12  · 技术社区  · 3 年前

    我有一个存储定义如下

        #[pallet::storage]
        #[pallet::getter(fn algos)]
        pub(super) type Algo<T: Config> = StorageMap<
            _,
            Blake2_128Concat, (T::AccountId, Vec<u8>),
            (T::Moment,Vec<u8>, T::BlockNumber),
            ValueQuery
        >;
    

    但是当我检查的时候

    ensure!(
        Algo::<T>::containkey(
        &(origin_account, algo_hash)
    ), Error::<T>::Exists);
    

    它抛出以下错误

        |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `EncodeLike<(<T as frame_system::Config>::AccountId, Vec<u8>)>` is not implemented for `&(Result<<T as frame_system::Config>::AccountId, frame_support::error::BadOrigin>, Vec<u8>)`
        |
        = note: required by `frame_support::pallet_prelude::StorageMap::<Prefix, Hasher, Key, Value, QueryKind, OnEmpty>::contains_key`
    help: consider introducing a `where` bound, but there might be an alternative better way to express this requirement
    
    impl<T: Config> Pallet<T> where &(Result<<T as frame_system::Config>::AccountId, frame_support::error::BadOrigin>, Vec<u8>): EncodeLike<(<T as frame_system::Config>::AccountId, Vec<u8>)> {
        |       
    

    如何修复此错误以支持检查StorageMap中的内容?

    0 回复  |  直到 3 年前
    推荐文章