Fair-Squares / fair-squares

Fair housing for all
http://www.fair-squares.nl
Apache License 2.0
16 stars 8 forks source link

Update approval waiting list management #238

Closed cuteolaf closed 1 year ago

cuteolaf commented 1 year ago

Motivation

We need to update the logic for managing the approval waiting list.

Currently, we have 4 storage items - SellerApprovalList, ServicerApprovalList, NotaryApprovalList and RepApprovalList.

#[pallet::storage]
#[pallet::getter(fn get_pending_house_sellers)]
pub(super) type SellerApprovalList<T: Config> =
    StorageValue<_, Vec<HouseSeller<T>>, ValueQuery, InitPendingSellerList<T>>;

#[pallet::storage]
#[pallet::getter(fn get_pending_servicers)]
pub(super) type ServicerApprovalList<T: Config> =
    StorageValue<_, Vec<Servicer<T>>, ValueQuery, InitPendingServicerList<T>>;

#[pallet::storage]
#[pallet::getter(fn get_pending_notaries)]
pub(super) type NotaryApprovalList<T: Config> =
    StorageValue<_, Vec<Notary<T>>, ValueQuery, InitPendingNotaryList<T>>;

#[pallet::storage]
#[pallet::getter(fn get_pending_representatives)]
///Approval waiting list for Representatives
pub type RepApprovalList<T: Config> =
    StorageMap<_, Twox64Concat, AccountIdOf<T>, Representative<T>, OptionQuery>;

If we want to check if a user has already requested a role, we need to see all of the 4 storage items - which is currently implemented in check_role_approval_list. This is not good enough both for back-end and front-end.

Suggested Solution We need to have a storage item that maps the accounts to their requested roles.

Something like

pub type RequestedRoles<T: Config> = StorageMap<_, Twox64Concat, AccountIdOf<T>, Accounts, OptionQuery>;
ndkazu commented 1 year ago

Is it right to understand that this storage will simplify things for the front-end??

ilhanu commented 1 year ago

Yeah so I talked to @cuteolaf it's indeed to simplify things on the front-end. This will be taken along in the UI when a council/sudo/server will approve the roles of pending new members.