virto-node icon indicating copy to clipboard operation
virto-node copied to clipboard

Estrinsic to mint memberships for sale

Open olanod opened this issue 9 months ago • 1 comments

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)?;
        /// ...
    }
}

olanod avatar Apr 26 '24 17:04 olanod

@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)?;
        /// ...
    }
}

pandres95 avatar May 03 '24 07:05 pandres95