import { useChannel } from '@sageprotocol/sdk/react';
import { useWallet } from '@suiet/wallet-kit';
function AddModerator({ channelId, moderatorSharedUserId }) {
const { addModerator } = useChannel();
const { account, signAndExecuteTransaction } = useWallet();
async function handleAddModerator() {
const result = await addModerator({
amounts: [0, 0], // Required protocol fees
appId: 'your-app-id', // Explicitly required application ID
network: 'testnet', // 'testnet' or 'mainnet'
channelId, // Channel ID to moderate
sharedUserId: moderatorSharedUserId, // User's shared ID to grant moderator role
self: account.address // Channel owner's wallet address
});
if (result.ok) {
await signAndExecuteTransaction({ transaction: result.transaction });
console.log("Moderator added successfully!");
} else {
console.error("Error adding moderator:", result.err);
}
}
return <button onClick={handleAddModerator}>Add Moderator</button>;
}
export default AddModerator;
Direct Javascript Example for Adding Moderators
import { SageClient } from '@sageprotocol/sdk';
const sageClient = new SageClient({
appId: 'your-app-id', // Explicitly required application ID
channelRegistryId: 'your-registry-id', // Required channel registry ID
network: 'testnet' // 'testnet' or 'mainnet'
});
await sageClient.initialize();
async function addModerator(channelId, moderatorSharedUserId, walletAddress) {
const result = await sageClient.addChannelModerator({
amounts: [0, 0], // Required protocol fees
channelId, // Channel ID to moderate
sharedUserId: moderatorSharedUserId, // Shared user ID to grant moderator role
self: walletAddress // Channel owner's wallet address
});
if (result.ok) {
await signAndExecuteTransaction({ transaction: result.transaction });
console.log("Moderator added successfully!");
} else {
console.error("Error adding moderator:", result.err);
}
}
addModerator('your-channel-id', 'moderator-shared-user-id', walletAddress);
import { useChannel } from '@sageprotocol/sdk/react';
import { useWallet } from '@suiet/wallet-kit';
function RemoveModerator({ channelId, moderatorSharedUserId }) {
const { removeModerator } = useChannel();
const { account, signAndExecuteTransaction } = useWallet();
async function handleRemoveModerator() {
const result = await removeModerator({
amounts: [0, 0], // Required protocol fees
appId: 'your-app-id', // Explicitly required application ID
network: 'testnet', // 'testnet' or 'mainnet'
channelId, // Channel ID to moderate
sharedUserId: moderatorSharedUserId, // User's shared ID whose moderator role will be revoked
self: account.address // Channel owner's wallet address
});
if (result.ok) {
await signAndExecuteTransaction({ transaction: result.transaction });
console.log("Moderator removed successfully!");
} else {
console.error("Error removing moderator:", result.err);
}
}
return <button onClick={handleRemoveModerator}>Remove Moderator</button>;
}
export default RemoveModerator;
Direct Javascript Example for Removing Moderators
import { SageClient } from '@sageprotocol/sdk';
const sageClient = new SageClient({
appId: 'your-app-id', // Explicitly required application ID
channelRegistryId: 'your-registry-id', // Required channel registry ID
network: 'testnet' // 'testnet' or 'mainnet'
});
await sageClient.initialize();
async function removeModerator(channelId, moderatorSharedUserId, walletAddress) {
const result = await sageClient.removeChannelModerator({
amounts: [0, 0], // Required protocol fees
channelId, // Channel ID to moderate
sharedUserId: moderatorSharedUserId, // Shared user ID whose moderator role will be revoked
self: walletAddress // Channel owner's wallet address
});
if (result.ok) {
await signAndExecuteTransaction({ transaction: result.transaction });
console.log("Moderator removed successfully!");
} else {
console.error("Error removing moderator:", result.err);
}
}
removeModerator('your-channel-id', 'moderator-shared-user-id', walletAddress);