I have an issue. I wold like to store a struct using AccountId as key:
#[derive(Clone, Copy, Encode, Decode, RuntimeDebug, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
pub struct Contract<Origin, AccountId, Amount> {
pub origin: Origin,
pub to: AccountId,
pub amount: Amount,
pub current_block_number: u64,
pub work_days_in_block_number: u64,
pub take_action_days_in_block: u64,
}
#[pallet::storage]
#[pallet::getter(fn contract_sender)]
pub(super) type ContractSender<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, Contract<T::AccountId, T::AccountId, BalanceOf<T>>, ValueQuery>;
#[pallet::storage]
#[pallet::getter(fn contract_receiver)]
pub(super) type ContractReceiver<T: Config> =
StorageMap<_, Blake2_128Concat, T::AccountId, Contract<T::AccountId, T::AccountId, BalanceOf<T>>, ValueQuery>;
But having this issue:
error[E0277]: the trait bound `Contract<<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId, <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance>: std::default::Default` is not satisfied
--> pallets/escrow/src/lib.rs:47:12
|
47 | #[pallet::pallet]
| ^^^^^^ the trait `std::default::Default` is not implemented for `Contract<<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId, <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance>`
|
= help: the trait `StorageInfoTrait` is implemented for `frame_support::pallet_prelude::StorageMap<Prefix, Hasher, Key, Value, QueryKind, OnEmpty, MaxValues>`
= note: required because of the requirements on the impl of `frame_support::traits::Get<Contract<<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId, <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance>>` for `GetDefault`
= note: required because of the requirements on the impl of `QueryKindTrait<Contract<<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId, <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance>, GetDefault>` for `frame_support::pallet_prelude::ValueQuery`
= note: required because of the requirements on the impl of `StorageInfoTrait` for `frame_support::pallet_prelude::StorageMap<_GeneratedPrefixForStorageContractSender<T>, frame_support::Blake2_128Concat, <T as frame_system::Config>::AccountId, Contract<<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId, <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance>, frame_support::pallet_prelude::ValueQuery>`
error[E0277]: the trait bound `Contract<<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId, <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance>: std::default::Default` is not satisfied
--> pallets/escrow/src/lib.rs:66:12
|
66 | #[pallet::storage]
| ^^^^^^^ the trait `std::default::Default` is not implemented for `Contract<<T as frame_system::Config>::AccountId, <T as frame_system::Config>::AccountId, <<T as pallet::Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance>`
I do not understand what's wrong :/ Any idea?