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

[feat] Channel implementation #113

Closed
wants to merge 0 commits into from

Conversation

PavitraAgarwal21
Copy link
Contributor

No description provided.

@@ -0,0 +1,305 @@
use starknet::ContractAddress;

#[derive(Drop, Serde, Clone, starknet::Store)]
Copy link
Collaborator

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

}

#[starknet::interface]
pub trait IChannel<TState> {
Copy link
Collaborator

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.

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;
Copy link
Collaborator

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

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
Copy link
Collaborator

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.

// 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;
Copy link
Collaborator

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.

struct Storage {
channels: LegacyMap<u256, channelParams>,
channel_counter: u256,
channel_members: LegacyMap<(u256, ContractAddress), bool>,
Copy link
Collaborator

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

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);
Copy link
Collaborator

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



fn join_channel(ref self: ContractState, channel_id: u256) {
// is we have to check some condition before he can join the channel
Copy link
Collaborator

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

fn remove_channel_mods(
ref self: ContractState, channel_id: u256, moderator: ContractAddress
) {
// only the primary moderator can add the moderators
Copy link
Collaborator

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

}

// what does the substiption means to the channel
fn upgrade_channel(ref self: ContractState, channel_id: u256) -> bool {
Copy link
Collaborator

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants