Publish comment
SDK
Installation
npm install @cyberlab/cyberconnect-v2
or
yarn add @cyberlab/cyberconnect-v2
Init CyberConnect
import CyberConnect, {
Env
} from '@cyberlab/cyberconnect-v2';
const cyberConnect = new CyberConnect({
appId: 'cyberconnect',
namespace: 'CyberConnect',
env: Env.Production,
provider: provider,
signingMessageEntity: 'CyberConnect' || your entity,
});
appId
- Your application id, can be any string less than 128 characters.namespace
- Your application name.env
- (optional) Env decides the endpoints. Now we havestaging
andproduction
. (The default value isEnv.Production
).provider
- The corresponding provider of the given chain.signingMessageEntity
- (optional) Use to describe the entity users sign their message with. Users will see it when authorizing in the walletI authorize ${signingMessageEntity} from this device using signing key:
. The default entity isCyberConnect
.
Creating comment
cyberConnect.createComment(targetContentId, content);
Parameters
targetContentId: string
- target content id to comment on, which can be a post, an essence or a commentcontent: Content
- comment content
interface Content {
title: string;
body: string;
author: string; // The ccProfile handle of the author
}
Return
response: PublishResponse
- publish response
type PublishResponse = {
status: Status;
contentID: string;
arweaveTxHash: string;
tsInServer: number;
};
enum Status {
SUCCESS,
INVALID_PARAMS,
RATE_LIMITED,
HANDLE_NOT_FOUND,
CONTENT_NOT_FOUND,
TARGET_NOT_FOUND,
NOT_PROFILE_OWNER,
ALREADY_EXISTED,
INVALID_MESSAGE,
INVALID_SIGNATURE,
MESSAGE_EXPIRED,
INVALID_SIGNING_KEY,
}
Updating comment
cyberConnect.updateComment(commentId,, targetContentId, content);
Parameters
commentId: string
- comment id to updatetargetContentId: string
- target content id to comment on, which can be a post, an essence or a commentcontent: Content
- new comment content
interface Content {
title: string;
body: string;
author: string; // The ccProfile handle of the author
}
Return
response: PublishResponse
- publish response
type PublishResponse = {
status: Status;
contentID: string;
arweaveTxHash: string;
tsInServer: number;
};
enum Status {
SUCCESS,
INVALID_PARAMS,
RATE_LIMITED,
HANDLE_NOT_FOUND,
CONTENT_NOT_FOUND,
TARGET_NOT_FOUND,
NOT_PROFILE_OWNER,
ALREADY_EXISTED,
INVALID_MESSAGE,
INVALID_SIGNATURE,
MESSAGE_EXPIRED,
INVALID_SIGNING_KEY,
}
Verifying the proof
After creating or updating a comment successfully, you can use arweaveTxHash
to verify the proof, go to https://arweave.app/tx/${arweaveTxHash}
.