-
Notifications
You must be signed in to change notification settings - Fork 30
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
[feat] Channel implementation #113
Conversation
src/channel/channel.cairo
Outdated
@@ -0,0 +1,305 @@ | |||
use starknet::ContractAddress; | |||
|
|||
#[derive(Drop, Serde, Clone, starknet::Store)] |
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.
move this into base/types
file
src/channel/channel.cairo
Outdated
} | ||
|
||
#[starknet::interface] | ||
pub trait IChannel<TState> { |
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.
move this to the interfaces folder. create an IChannel.cairo
file.
src/channel/channel.cairo
Outdated
ref self: TState, channel_id: u256, profile: ContractAddress, ban_status: bool | ||
); | ||
// fn premium_subscription(ref self: TState, channel_id: u256) -> bool; | ||
fn upgrade_channel(ref self: TState, channel_id: u256) -> bool; |
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'd be scraping the ideas of a premium channel for now. so let's take away the upgrade_channel
src/channel/channel.cairo
Outdated
fn get_channel_metadata_uri(self: @TState, channel_id: u256) -> ByteArray; | ||
// so is the profile is channel member or not we have to say that which channel id , i think it will be good | ||
fn is_channel_member(self: @TState, profile: ContractAddress) -> (bool, u256); | ||
// what is the means by the paid channel member |
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'd be scraping any idea of paid channel or paid member for now.
src/channel/channel.cairo
Outdated
// what is the means by the paid channel member | ||
// fn is_paid_channel_member(self: @TState, profile: ContractAddress) -> (bool, u256); | ||
// how we can calcualte the get_total_member | ||
// fn get_total_members(self: @TState, channel_id: u256) -> u256; |
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.
total_members is a struct item in the channelParams. you can simply return that.
src/channel/channel.cairo
Outdated
struct Storage { | ||
channels: LegacyMap<u256, channelParams>, | ||
channel_counter: u256, | ||
channel_members: LegacyMap<(u256, ContractAddress), bool>, |
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.
channel members should map to a struct called channelMember. details of this struct would be added to the notion docs
src/channel/channel.cairo
Outdated
self.channel_moderators.read((channel_id, get_caller_address())), | ||
"You are not the moderator of the channel" | ||
); | ||
self.channel_members.write((channel_id, profile), ban_status); |
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.
doing this alone exposes a vulnerability. banned members could easily just join back again. instead we are going to also have a ban_status
in the channelMember struct that gets updated to true. and we check this when a user tries to join a channel
src/channel/channel.cairo
Outdated
|
||
|
||
fn join_channel(ref self: ContractState, channel_id: u256) { | ||
// is we have to check some condition before he can join the channel |
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.
let's check that the user was not previously banned
src/channel/channel.cairo
Outdated
fn remove_channel_mods( | ||
ref self: ContractState, channel_id: u256, moderator: ContractAddress | ||
) { | ||
// only the primary moderator can add the moderators |
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.
should be done by the primary mod alone
src/channel/channel.cairo
Outdated
} | ||
|
||
// what does the substiption means to the channel | ||
fn upgrade_channel(ref self: ContractState, channel_id: u256) -> bool { |
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.
let's remove this function
No description provided.