Fair-Squares / fair-squares

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

Add new roles and permissions #196

Closed ilhanu closed 1 year ago

ilhanu commented 1 year ago

Add new roles and permission, the actions these new roles can have are currently limited to the below list of actions.

  1. Notary (can finalize the sale)
graph LR
A[Asset]-- reserved -->B[Notary]
B --> C[Finalize]
C-- purchased -->D[Asset]

The notary can finalize the sale and the asset will be purchased. Also the notary can reject the sale and the asset will be back to the rejected state and the owner can decide to sell it or to delist the asset.

The cost for the notary will be paid from the bond the seller proposed.  

  1. Representative (can propose a tenant)

    graph LR
    A[Asset]-- purchased -->B[Representative]
    B --> C[Propose Tenant]
    C-- accepted -->D[Asset]

    The representative can propose a tenant and the owners can vote on it. The cost for the representative will be paid from the virtual account, which is the account that holds the funds for the asset and is of the owners.

  2. Owners (can vote on governance)

    graph LR
    A[Asset]-- purchased -->B[Owners]
    B --> C[Vote]
    C-- tally -->D[Asset]

    The owners are the investors, what makes the distinction is that they own asset of the specific unique asset.

Currently the only flow we are implementing is the appointing of a representative. The owners can vote on it and the tally will be done by the democracy pallet. The cost for the owners will be paid from the virtual account, which is the account that holds the funds for the asset and is of the owners.

ndkazu commented 1 year ago

Notes:

//----------------------------------------------------------------------------------------------------------------
//-------------REPRESENTATIVE STRUCT DECLARATION & IMPLEMENTATION_BEGIN----------------------
#[derive(Clone, Encode, Decode, Default, PartialEq, Eq, TypeInfo)]
#[scale_info(skip_type_params(T))]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct Representative<T: Config> {
    pub account_id: T::AccountId,
    pub age: BlockNumberOf<T>,
    pub activated: bool,
    pub assets_accounts: Vec<T::AccountId>,
}
impl<T: Config> Representative<T>
where
    types::Representative<T>: EncodeLike<types::Representative<T>>,
{
    //--------------------------------------------------------------------
    //-------------REPRESENTATIVE CREATION METHOD_BEGIN----------------------
    pub fn new(acc: OriginFor<T>) -> DispatchResult {
        let caller = ensure_signed(acc)?;
        let now = <frame_system::Pallet<T>>::block_number();
        ensure!(!RepresentativeLog::<T>::contains_key(&caller), Error::<T>::NoneValue);

        let rep = Representative { account_id: caller, age: now, activated: false, assets_accounts: Vec::new()};

        RepApprovalList::<T>::mutate(|val| {
            val.0.push(hw);
        });

        Ok(())
    }
    //-------------HOUSE SELLER CREATION METHOD_END----------------------
    //------------------------------------------------------------------
}

//-------------REPRESENTATIVE STRUCT DECLARATION & IMPLEMENTATION_END----------------------
//--------------------------------------------------------------------------------------------------------------