Moderation
Adding or removing a moderator will only succeed for an owner of a channel.
Add a Sage channel moderator
import { useSignAndExecuteTransaction } from '@mysten/dapp-kit';
import { useUser } from '@sage-app/sdk/react';
interface ChannelModeratorInput {
amounts: number[]; // payment amounts set to [0, 0]
channelId: string; // channel address
self: string; // user's wallet address
soulId: string; // address of user's owned soul
}
...
const { mutateAsync: signAndExecuteTransaction } = useSignAndExecuteTransaction();
const { addModerator } = useChannel();
...
const addChannelModerator = async (data: ChannelModeratorInput) => {
const { ok, err, transaction } = await addModerator(data);
const { digest } = await signAndExecuteTransaction({
transaction
});
};
Error Codes
Channel Fees module
Code
Value
Meaning
370
EIncorrectCoinType
Custom payment type does not match configured custom payment coin.
371
EIncorrectCustomPayment
Incorrect custom payment value.
372
EIncorrectSuiPayment
Incorrect sui payment value.
Moderation module
Code
Value
Meaning
372
EIsNotOwner
User is not the owner of the channel.
Remove a Sage channel moderator
import { useSignAndExecuteTransaction } from '@mysten/dapp-kit';
import { useUser } from '@sage-app/sdk/react';
interface ChannelModeratorInput {
amounts: number[]; // payment amounts set to [0, 0]
channelId: string; // channel address
self: string; // user's wallet address
soulId: string; // address of user's owned soul
}
...
const { mutateAsync: signAndExecuteTransaction } = useSignAndExecuteTransaction();
const { removeModerator } = useChannel();
...
const removeChannelModerator = async (data: ChannelModeratorInput) => {
const { ok, err, transaction } = await removeModerator(data);
const { digest } = await signAndExecuteTransaction({
transaction
});
};
Error Codes
Channel Fees module
Code
Value
Meaning
370
EIncorrectCoinType
Custom payment type does not match configured custom payment coin.
371
EIncorrectCustomPayment
Incorrect custom payment value.
372
EIncorrectSuiPayment
Incorrect sui payment value.
Moderation module
Code
Value
Meaning
372
EIsNotOwner
User is not the owner of the channel.
Querying for Channel Moderation Events
import { EventId, SuiClient, getFullnodeUrl } from '@mysten/sui/client';
import { SageClient } from '@sage-app/sdk/client';
...
interface QueryInput {
cursor?: EventId;
}
const appId = '<YOUR_APP_ID>';
const network = 'mainnet' | 'testnet';
const suiClient = new SuiClient({ url: getFullnodeUrl(network) });
const sageClient = new SageClient({ appId, network, suiClient });
...
const pollUserModerationChanges = async ({ cursor }) => {
const {
eventCount,
events,
hasNextPage,
nextCursor
} = await sageClient.queryChannelModerationEvents({ cursor }: QueryInput);
// do something with events
setTimeout(() => pollUserModerationChanges({ cursor: nextCursor }), 5000);
};
In this case events will take the shape of an array of ChannelModerationEvent:
interface ChannelModerationEvent {
channelKey: string; // <= e.g. "sui-play" (unique value, lowercase)
message: "JOIN" | "LEAVE";
moderatorType: "OWNER" | "MODERATOR";
updatedAt: string;
user: string; // <= user's address
}
Last updated