-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: main
Are you sure you want to change the base?
Subscriptions pallet #147
Conversation
Extend SpacesInterface
80e8049
to
e472c50
Compare
c0c8428
to
446b3ab
Compare
/// The balance required to subscribe to a space. | ||
pub subscription: Balance, | ||
|
||
/// Determines if subscriptions for a space s disabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Determines if subscriptions for a space s disabled. | |
/// Determines if subscriptions for a space is disabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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 { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Yung-Beef plz check
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, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unused imports.
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); |
There was a problem hiding this comment.
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::*; |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 } |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, can we rewrite?
No description provided.