(Desktop only) Edit your community settings
(Desktop only) Edit your community settings in Bitsocial React Hooks. Usage, options, and examples.
If the account’s pkc client hosts the community (it is listed in pkc.communities), the edit is applied locally. Otherwise it is published as a CommunityEdit over pubsub, even when the account is the owner, and the hosting node accepts it from the owner or an admin (only the owner can change address or roles).
const onChallenge = async (challenge, communityEdit) => {
let challengeAnswers
try {
challengeAnswers = await getChallengeAnswersFromUser(challenge.challenges)
}
catch (e) {}
if (challengeAnswers) {
await communityEdit.publishChallengeAnswers(challengeAnswers)
}
}
const onChallengeVerification = (challengeVerification, communityEdit) => {
console.log('challenge verified', challengeVerification)
}
const onError = (error, communityEdit) => console.error(error)
// add ENS to your community
const editCommunityOptions = {
communityAddress: '12D3KooWANwdyPERMQaCgiMnTT1t3Lr4XLFbK1z4ptFVhW2ozg1z', // the previous address before changing it
address: 'your-community-address.eth', // the new address to change to
onChallenge,
onChallengeVerification,
onError
}
await publishCommunityEdit()
// edit other community settings
const editCommunityOptions = {
communityAddress: 'your-community-address.eth', // the address of the community to change
title: 'Your title',
description: 'Your description',
onChallenge,
onChallengeVerification,
onError
}
const {publishCommunityEdit} = usePublishCommunityEdit(editCommunityOptions)
await publishCommunityEdit()
// verify if ENS was set correctly, use {cache: false} or it won't update
const {resolvedAddress} = useResolvedCommunityAddress({communityAddress: 'your-community-address.eth', cache: false})
// result
if (state === 'succeeded') {
console.log('Succeeded resolving address', resolvedAddress)
console.log('ENS set correctly', resolvedAddress === community.signer.address)
}
if (state === 'failed') {
console.log('Failed resolving address', error.message)
}
// pending
if (state === 'resolving') {
console.log('Resolving address from chain provider URL', chainProvider.urls)
}