virto-network / virto-node

Virto Network blockchain node.
GNU General Public License v3.0
21 stars 10 forks source link

Estrinsic to mint memberships for sale #378

Closed olanod closed 4 months ago

olanod commented 4 months ago

We want a simple privileged extrinsic(for the root track) in the communities manager to mint memberships in bulk wit a given type. The pallet can define a constant that represents the kinds of memberships the protocol has to offer and the extrinsic can receive a starting id and number of memberships to be minted. e.g.

enum MemKind {
    Special,
    ForLife(DailyGas),
    Limited(Validity, DailyGas),
}

impl<T: Config> Pallet<T> {
    pub fn mint_memberships(
        origin: OriginFor<T>, ) {
        start: MembershipIfOf<T>,
        quantity: u16,
        kind: MemKind,
        price: BalanceOf<T>,
    ) {
        T::MintOrigin::ensure_origin(origin)?;
        /// ...
    }
}
pandres95 commented 4 months ago

@olanod how about replacing DailyGas with a restart period and a Weight to express the weight consumable during that period? Like this:

pub struct GasRules<Moment> {
    pub reset_period: Moment;
    pub weight_in_period: Weight;
}

pub enum MemKind<Moment> {
    Special,
    ForLife(GasRules<Moment>),
    Limited(Validity, GasRules<Moment>),
}

// ...

impl<T: Config> Pallet<T> {
    pub fn mint_memberships(
        origin: OriginFor<T>, ) {
        start: MembershipIfOf<T>,
        quantity: u16,
        kind: MemKind<BlockNumberFor<T>>,
        gas_ruies: GasRules<BlockNumberFor<T>>
        price: BalanceOf<T>,
    ) {
        T::MintOrigin::ensure_origin(origin)?;
        /// ...
    }
}