I am creating a parachain with a custom pallet, where i have this set up in storage:
pub type AccountIdOf<T> = <T as frame_system::Config>::AccountId;
pub type NeuronMetadataOf<T> = NeuronMetadata<AccountIdOf<T>>;
pub type BalanceOf<T> = <<T as Config>::Currency as Currency<<T as frame_system::Config>::AccountId>>::Balance;
#[derive(Clone, Encode, Decode, Eq, PartialEq, RuntimeDebug, TypeInfo)]
pub struct NeuronMetadata<AccountId> {
/// ---- The associated hotkey account.
/// Registration and changing weights can be made by this
/// account.
pub key1: AccountId,
pub key2: AccountId,
}
#[pallet::storage]
#[pallet::getter(fn uid)]
pub(super) type Neurons<T:Config> = StorageMap<
_,
Identity,
u32,
NeuronMetadataOf<T>,
ValueQuery
>;
#[cfg(feature = "std")]
impl<T> Default for NeuronMetadata<T> {
fn default() -> Self {
Self {
key1: Default::default(),
key2: Default::default(),
}
}
My understanding is AccountId is not designed to be bound to Default. A "default" AccountId doesn't make any sense to have and it helped mask a previous issue and so it was removed in a recent release. (This is from: Why is there no `Default` implementation for `T::AccountId`?). However now that I've defined a Default implementation for it, I keep getting an error that says
error[E0277]: the trait bound `T: std::default::Default` is not satisfied
--> pallets/subtensor/src/lib.rs:245:13
|
245 | key1: Default::default(),
| ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `T`
|
note: required by `std::default::Default::default`
So my question is, I don't understand how to manually define Default
for an AccountId
struct like NeuronMetaData<AccountId>
. Any examples would be super helpful here.