I was making a function to store the some data in the pallet. #[pallet::storage] #[pallet::getter(fn number)] // Learn more about declaring storage items: // https://docs.substrate.io/main-docs/build/runtime-storage/#declaring-storage-items
pub type Number<T> = StorageMap<_, Blake2_128Concat,u32,Vec<u8>,ValueQuery>;
#[pallet::weight(10_000 + T::DbWeight::get().writes(1).ref_time())]
pub fn store_data(origin: OriginFor<T>, number: u32, data: Vec<u8>) -> DispatchResult {
// Check that the extrinsic was signed and get the signer.
// This function will return an error if the extrinsic is not signed.
// https://docs.substrate.io/main-docs/build/origins/
let who = ensure_signed(origin)?;
// Update storage.
<Number<T>>::insert(number,data.clone());
// Emit an event.
Self::deposit_event(Event::SomethingStored ( who.clone(),number.clone(),data.clone() ));
// Return a successful DispatchResultWithPostInfo
Ok(())
}
And i was making a function in which i want to print the current existing data of the particular storage.
#[pallet::weight(10_000 + T::DbWeight::get().writes(1).ref_time())]
pub fn show_data(origin: OriginFor<T>,number: u32, data: Vec<u8> ) -> DispatchResult {
// Check that the extrinsic was signed and get the signer.
// This function will return an error if the extrinsic is not signed.
let who = ensure_signed(origin)?;
// Update storage.
<Number<T>>::get(number);
<Number<T>>::get(data.clone());
// Emit an event.
Self::deposit_event(Event::Data(who.clone(),number.clone(),data.clone()));
Ok(())
}
In the number(u32) is working fine. But in the get(Vec) is showing
the trait EncodeLike<u32>
is not implemented for Vec<u8>