use std::string;
use sui::clock;
use sui::coin;
use sui::event;
use sui::sui;
use sage_admin::admin;
use sage_admin::admin_access;
use sage_admin::apps;
use sage_admin::fees;
use sage_analytics::analytics_actions;
use sage_channel::channel;
use sage_channel::channel_fees;
use sage_channel::channel_registry;
use sage_channel::channel_witness;
use sage_post::post_actions;
use sage_rewards::reward_registry;
use sage_shared::membership;
use sage_shared::moderation;
use sage_user::user_owned;
use sage_user::user_registry;
use sage_user::user_shared;
use sage_utils::string_helpers;

Explore this module further in the Mover Registry: @sage/channel

Events

ChannelCreated

Emitted when a new Channel is created.

public struct ChannelCreated has copy, drop

ChannelFollowsUpdate

Emitted when a User is follows or unfollows a Channel.

public struct ChannelFollowsUpdate has copy, drop

ChannelModerationUpdate

Emitted when a Moderator is added or removed from a Channel.

public struct ChannelModerationUpdate has copy, drop

ChannelPostCreated

Emitted when a new Post is created for a Channel.

public struct ChannelPostCreated has copy, drop

ChannelUpdated

Emitted when a Channel is updated.

public struct ChannelUpdated has copy, drop

Constants

Attempted to change the channel name to a different value. Channel names can only change the displayed case (e.g. “my-channel” to “my-CHANNEL”).

const EChannelNameMismatch: u64 = 370;

Functions

add_moderator_as_owner

Adds a moderator to the channel. Aborts with EIsNotOwner if the transaction was not executed by the channel owner and EIncorrectCoinType, EIncorrectCustomPayment, or EIncorrectSuiPayment if the payment was incorrect.

public fun add_moderator_as_owner<CoinType> (channel: &mut Channel, channel_fees: &ChannelFees, clock: &Clock, shared_user: &UserShared, custom_payment: sui::coin::Coin<CoinType>, sui_payment: sui::coin::Coin<SUI>, ctx: &mut TxContext) 

create

Creates a new Channel. Aborts with EAppChannelRegistryMismatch if the ChannelRegistry does not belong to the App, and EIncorrectCoinType, EIncorrectCustomPayment, or EIncorrectSuiPayment if the payment was incorrect.

public fun create<CoinType> (app: &App, channel_fees: &ChannelFees, channel_registry: &mut ChannelRegistry, channel_witness_config: &ChannelWitnessConfig, clock: &Clock, reward_weights_registry: &RewardWeightsRegistry, owned_user: &mut UserOwned, user_witness_config: &UserWitnessConfig, avatar: String, banner: String, description: String, name: String, custom_payment: Coin<CoinType>, sui_payment: Coin<SUI>, ctx: &mut TxContext): address

create_registry

Creates a new channel registry for an App.

public fun create_registry(app_channel_registry: &mut AppChannelRegistry, app: &App, ctx: &mut TxContext)

follow

A User follows a Channel. Aborts with EAppChannelMismatch if the Channel does not belong to the App, EIsMember if the User already follows the Channel, and EIncorrectCoinType, EIncorrectCustomPayment, or EIncorrectSuiPayment if the payment was incorrect.

public fun follow<CoinType> (app: &App, channel: &mut Channel, channel_fees: &ChannelFees, channel_witness_config: &ChannelWitnessConfig, clock: &Clock, reward_weights_registry: &RewardWeightsRegistry, owned_user: &mut UserOwned, user_witness_config: &UserWitnessConfig, custom_payment: Coin<CoinType>, sui_payment: Coin<SUI>, ctx: &mut TxContext)

post

Creates a Post on the Channel. Aborts with EIsNotMember if the User is not following the Channel, and EIncorrectCoinType, EIncorrectCustomPayment, or EIncorrectSuiPayment if the payment was incorrect.

public fun post<CoinType> (app: &App, channel: &mut Channel, channel_fees: &ChannelFees, channel_witness_config: &ChannelWitnessConfig, clock: &Clock, reward_weights_registry: &RewardWeightsRegistry, owned_user: &mut UserOwned, user_witness_config: &UserWitnessConfig, data: String, description: String, title: String, custom_payment: Coin<CoinType>, sui_payment: Coin<SUI>, ctx: &mut TxContext): (address, u64)

remove_moderator_as_owner

Removes a User as a Moderator on the Channel. Aborts with EIsNotOwner if the User is not owner of the Channel, and EIncorrectCoinType, EIncorrectCustomPayment, or EIncorrectSuiPayment if the payment was incorrect.

public fun remove_moderator_as_owner<CoinType> (channel: &mut Channel, channel_fees: &ChannelFees, clock: &Clock, shared_user: &UserShared, custom_payment: Coin<CoinType>, sui_payment: Coin<SUI>, ctx: &mut TxContext)

unfollow

User unfollows a Channel.

public fun unfollow<CoinType> (channel: &mut Channel, channel_fees: &ChannelFees, clock: &Clock, custom_payment: Coin<CoinType>, sui_payment: Coin<SUI>, ctx: &mut TxContext)

update_as_owner

Update Channel metadata. The lowercase value of the name cannot be edited, but the casing can. Aborts with EIsNotModerator if the User is not a moderator of the Channel, EChannelNameMismatch if anything about the name is changed other than casing, and EIncorrectCoinType, EIncorrectCustomPayment, or EIncorrectSuiPayment if the payment was incorrect.

public fun update_as_owner<CoinType> (channel: &mut Channel, channel_fees: &ChannelFees, clock: &Clock, avatar: String, banner: String, description: String, name: String, custom_payment: Coin<CoinType>, sui_payment: Coin<SUI>, ctx: &mut TxContext)