Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscriptions pallet #147

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

TarekkMA
Copy link
Contributor

No description provided.

@siman siman changed the title Subscription pallet Subscriptions pallet Oct 6, 2022
@TarekkMA TarekkMA force-pushed the tarekkma/subscription-pallet branch from 80e8049 to e472c50 Compare October 27, 2022 09:14
@TarekkMA TarekkMA force-pushed the tarekkma/subscription-pallet branch from c0c8428 to 446b3ab Compare November 14, 2022 16:49
@F3Joule F3Joule added help wanted Extra attention is needed question Further information is requested labels Dec 27, 2022
/// The balance required to subscribe to a space.
pub subscription: Balance,

/// Determines if subscriptions for a space s disabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Determines if subscriptions for a space s disabled.
/// Determines if subscriptions for a space is disabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Determines if subscriptions for a space s disabled.
/// Determines if subscriptions for a space are disabled.

}

#[pallet::weight(< T as Config >::WeightInfo::unsubscribe())]
pub fn unsubscribe(origin: OriginFor<T>, space_id: T::SpaceId) -> DispatchResult {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk a reason why we dont clean the storage after unsubscribing

pub disabled: bool,

/// The id of the role that will be granted for space subscriber.
pub role_id: RoleId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we not put a permissions array here and create a role in extrinsic?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not here. Why should we store permissions set here if we'll store it in a role?
I think you meant to provide permissions set to an extrinsic, create a role using RolesInterface, and then put the role id here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, can we rewrite?

granted_role: T::RoleId,
price: BalanceOf<T>,
},
UserUnSubscribed {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UserUnSubscribed {
UserUnsubscribed {

impl<T: Config> RolesInterface<RoleId, SpaceId, T::AccountId, SpacePermission, T::BlockNumber>
for Pallet<T>
{
fn get_role_space(role_id: RoleId) -> Result<SpaceId, DispatchError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn get_role_space(role_id: RoleId) -> Result<SpaceId, DispatchError> {
fn get_role_space_id(role_id: RoleId) -> Result<SpaceId, DispatchError> {

Ok(role.space_id)
}

fn grant_role(account_id: T::AccountId, role_id: RoleId) -> DispatchResult {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always use just account or a descriptive name for a specific account.

Suggested change
fn grant_role(account_id: T::AccountId, role_id: RoleId) -> DispatchResult {
fn grant_role(account: T::AccountId, role_id: RoleId) -> DispatchResult {

@@ -0,0 +1,11 @@
# Subscriptions Pallet
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yung-Beef plz check

Comment on lines +1 to +21
use std::borrow::Borrow;

use codec::Decode;
use frame_support::{
dispatch::{DispatchError, DispatchResult},
parameter_types,
traits::{Everything, Get},
};
use sp_core::H256;
use sp_io::TestExternalities;
use sp_runtime::{
testing::Header,
traits::{BlakeTwo256, IdentityLookup},
};
use sp_std::convert::{TryFrom, TryInto};

use pallet_permissions::SpacePermission;
use subsocial_support::{
traits::{RolesInterface, SpacesInterface},
Content,
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove unused imports.

Comment on lines +97 to +104
parameter_types! {
pub static get_space_owner__return: Result<AccountId, DispatchError> = Ok(AccountId::decode(&mut sp_runtime::traits::TrailingZeroInput::zeroes()).unwrap());
pub static create_space__return: Result<SpaceId, DispatchError> = Ok(101);
}

clearable_parameter_type!(pub static get_space_owner__space_id: SpaceId);
clearable_parameter_type!(pub static create_space__owner: AccountId);
clearable_parameter_type!(pub static create_space__content: Content);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This produces plenty of warnings. Why not to use mockall here?

@@ -0,0 +1,30 @@
use frame_support::pallet_prelude::*;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yung-Beef this file plz

pub disabled: bool,

/// The id of the role that will be granted for space subscriber.
pub role_id: RoleId,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not here. Why should we store permissions set here if we'll store it in a role?
I think you meant to provide permissions set to an extrinsic, create a role using RolesInterface, and then put the role id here.

@@ -36,6 +36,7 @@ pallet-roles = { path = '../pallets/roles', default-features = false }
pallet-space-follows = { path = '../pallets/space-follows', default-features = false }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to put pallet-subscriptions to std

/// The balance required to subscribe to a space.
pub subscription: Balance,

/// Determines if subscriptions for a space s disabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Determines if subscriptions for a space s disabled.
/// Determines if subscriptions for a space are disabled.

/// Determines if subscriptions for a space s disabled.
pub disabled: bool,

/// The id of the role that will be granted for space subscriber.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The id of the role that will be granted for space subscriber.
/// The id of the role that will be granted for a space subscriber.

pub role_id: RoleId,
}

/// Information about space subscriber.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Information about space subscriber.
/// Information about a space subscriber.

/// Information about space subscriber.
#[derive(Encode, Decode, Clone, Eq, PartialEq, RuntimeDebug, TypeInfo, MaxEncodedLen)]
pub struct SubscriberInfo<Balance, RoleId, BlockNumber> {
/// The block number at which the subscriptions became active.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The block number at which the subscriptions became active.
/// The block number at which a subscription became active.

/// The block number at which the subscriptions became active.
pub subscribed_on: BlockNumber,

/// The balance paid for the subscriptions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The balance paid for the subscriptions.
/// The balance paid for the subscription.

@@ -0,0 +1,11 @@
# Subscriptions Pallet

Subscribing to a space is something similar to following a space, except subscribers will be granted a role for the space. This role can have any set of permissions space owner chooses to allow.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Subscribing to a space is something similar to following a space, except subscribers will be granted a role for the space. This role can have any set of permissions space owner chooses to allow.
Subscribing to a space is similar to following a space, except subscribers will be granted a role in the space. This role can have any set of permissions that the space owner chooses to allow.


Subscribing to a space is something similar to following a space, except subscribers will be granted a role for the space. This role can have any set of permissions space owner chooses to allow.

For the first version of this pallet subscription is meant to be only one time payment. But in the future we will allow recurring subscription.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For the first version of this pallet subscription is meant to be only one time payment. But in the future we will allow recurring subscription.
For the first version of this pallet, a subscription is just a one time payment, but in the future, we will allow recurring subscription payments.


For the first version of this pallet subscription is meant to be only one time payment. But in the future we will allow recurring subscription.

The space owner at any time can disable this role, and sets a new subscription settings with a new role.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The space owner at any time can disable this role, and sets a new subscription settings with a new role.
The space owner can disable this role at any time, and create a new subscription type with a new role.

This seems pretty shitty for end users.. I pay today and can lose my role tomorrow? We'll need some disclaimers on the UI


The space owner at any time can disable this role, and sets a new subscription settings with a new role.

The space owner can change the subscription value and it will be effective for new subscribers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The space owner can change the subscription value and it will be effective for new subscribers.
At any time, the space owner can change the cost of subscribing for new subscribers.


The space owner can change the subscription value and it will be effective for new subscribers.

Old subscribers can still enjoy the role they have been granted as long as the role is not disabled.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Old subscribers can still enjoy the role they have been granted as long as the role is not disabled.
Old subscribers can still enjoy their roles as long as those roles have not disabled.

@siman
Copy link
Member

siman commented Feb 6, 2023

Task linked: CU-861m92u45 Release Subscriptions pallet

pub disabled: bool,

/// The id of the role that will be granted for space subscriber.
pub role_id: RoleId,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, can we rewrite?

@siman
Copy link
Member

siman commented Feb 17, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants