Like content
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 applciation 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
.
Like content
cyberConnect.like(id);
Parameters
id: string
- The content id to like which can the id of a post, comment or an essence.
Return
response: LikeResponse
- like response
type LikeResponse = {
status: Status;
};
enum Status {
SUCCESS,
INVALID_PARAMS,
RATE_LIMITED,
TARGET_NOT_FOUND,
ALREADY_DONE,
INVALID_MESSAGE,
INVALID_SIGNATURE,
MESSAGE_EXPIRED,
}
Dislike post
cyberConnect.dislike(id);
Parameters
id: string
- The content id to dislike which can the id of a post, comment or an essence.
Return
response: DislikeResponse
- dislike response
type DislikeResponse = {
tsInServer: number;
status: Status;
};
enum Status {
SUCCESS,
INVALID_PARAMS,
RATE_LIMITED,
TARGET_NOT_FOUND,
ALREADY_DONE,
INVALID_MESSAGE,
INVALID_SIGNATURE,
MESSAGE_EXPIRED,
}
Cancel reaction
cyberConnect.cancelReaction(id);
Parameters
id: string
- The content id to cancel reaction on which can the id of a post, comment or an essence.
Return
response: CancelReactionResponse
- cancel reaction response
type CancelReactionResponse = {
status: Status;
};
enum Status {
SUCCESS,
INVALID_PARAMS,
RATE_LIMITED,
TARGET_NOT_FOUND,
ALREADY_DONE,
INVALID_MESSAGE,
INVALID_SIGNATURE,
MESSAGE_EXPIRED,
}
Verify the proof
After liking or disliking content successfully, you can use arweaveTxHash
to verify the proof, go to https://arweave.app/tx/${arweaveTxHash}
.