1

I am trying to upgrade pallet-did to substrate v4 but i have an issue am facing with the StorageMap implementation. Below is the code for the storage map functions i am trying to implement:

#[pallet::storage]
#[pallet::getter(fn delegate_of)]
pub type DelegateOf<T: Config> =
StorageMap<_, Blake2_128Concat, (T::AccountId, Vec<u8>, T::AccountId), Option<T::BlockNumber>, OptionQuery>;
    
    
#[pallet::storage]
#[pallet::getter(fn attribute_of)]
pub type AttributeOf<T: Config> =
StorageMap<_, Blake2_128Concat, (T::AccountId, [u8; 32]), Attribute<T::BlockNumber, T::Moment>, OptionQuery>;
    
#[pallet::storage]
#[pallet::getter(fn nonce_of)]
pub type AttributeNonce<T: Config> =
StorageMap<_, Twox64Concat, (T::AccountId, Vec<u8>), u64, ValueQuery>;
    
#[pallet::storage]
#[pallet::getter(fn owner_of)]
pub type OwnerOf<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, Option<T::AccountId>, OptionQuery>;
    
#[pallet::storage]
#[pallet::getter(fn updated_by)]
pub type UpdatedBy<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, (T::AccountId, T::BlockNumber, T::Time), OptionQuery>;

This is the decl_storage! functionality in pallet-did refactored into StorageMap functions. I get the following error:

warning: trait objects without an explicit dyn are deprecated
   --> src/lib.rs:128:5
    |
128 |     StorageMap<_, Blake2_128Concat, (T::AccountId, Vec<u8>, T::AccountId), Option<T::BlockNumber>, OptionQuery>;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!
    = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
    = note: #[warn(bare_trait_objects)] on by default
help: use dyn
    |
128 |     dyn StorageMap<_, Blake2_128Concat, (T::AccountId, Vec<u8>, T::AccountId), Option<T::BlockNumber>, OptionQuery>;
    |     +++

This doesn't make sense to me since StorageMap is a type and not a trait. A solution to this and explanation would be highly appreciated.

1 Answer 1

0

I'm not sure about this.

But from your log.

warning: this is accepted in the current edition (Rust 2018) but is a hard error in Rust 2021!

What's your rust version? Did you try the latest nightly toolchain?


After checking your code.

Because you wrote:

use frame_support::{
    dispatch::DispatchResult, ensure,traits::{Time, IsType}, StorageMap,
    sp_runtime::traits::{Scale, IdentifyAccount, Member, Verify},
};

This StorageMap shadows the same name type from the frame_support::pallet_prelude::*.

Please remove it, or change it to StorageMap as _.

7
  • I am using rustc 1.64.0 (a55dd71d5 2022-09-19), rustc 1.66.0-nightly (c97d02cdb 2022-10-05) Dec 20, 2022 at 8:18
  • I see. The log is a warning, not an error. Could you put the full log here? Or could you push your branch? I'll take a look. Dec 20, 2022 at 8:41
  • Thank you, i have pushed the code here github.com/ArnoldTumukunde/pallet-did/tree/… Dec 20, 2022 at 8:50
  • I didn't see any update. It still uses decl macro. Dec 20, 2022 at 9:24
  • Checkout the branch upgrade-to-substrate-v4 Dec 20, 2022 at 9:43

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.