I'm working with a StorageMap and want to return a dynamic default value based on the queried key when the key isn't found. Here's my attempt:
#[pallet::storage]
#[pallet::getter(fn asset)]
pub(super) type Asset<T: Config> =
StorageMap<_, Blake2_128Concat, U256, T::AccountId, ValueQuery, GetDefault<T::AccountId>>;
pub struct GetDefault<T>(sp_std::marker::PhantomData<T>);
impl<AccountId> Get<AccountId> for GetDefault<AccountId> {
fn get() -> AccountId {
// logic to derive dynamic default value based on asset_id
}
}
Is there a way to achieve this?