Skip to content

@ecp.eth/sdk


@ecp.eth/sdk / comments

comments

Ethereum Comments Protocol SDK Comments Core functionality for managing comments and approvals

Enumerations

EnumerationDescription
AuthorAuthMethod-
MetadataOperation-

Type Aliases

Type AliasDescription
AddApprovalParams-
AddApprovalResult-
AddApprovalTypedDataSchemaType-
AddApprovalWithSigParams-
AddApprovalWithSigResult-
AddCommentTypedDataSchemaType-
BaseEditCommentDataParams-
CommentDataThe data structure of a comment returned by the contract
CommentInputDataComment input data schema. This is used as input of the functions.
CommentManagerABIType-
CommentTypeSchemaType-
ContractReadFunctions-
ContractWriteFunctions-
CreateApprovalTypedDataParams-
CreateApprovalTypedDataResult-
CreateCommentData-
CreateCommentDataParams-
CreateCommentDataParamsSharedThe shared parameters for creating a comment
CreateCommentTypedDataParams-
CreateDeleteCommentTypedDataParams-
CreateEditCommentTypedDataParams-
CreateRemoveApprovalTypedDataParams-
CreateRemoveApprovalTypedDataResult-
CreateReplyCommentDataParamsThe parameters for creating a reply comment
CreateReportCommentTypedDataParams-
CreateRootCommentDataParamsThe parameters for creating a root comment
DeleteCommentParams-
DeleteCommentResult-
DeleteCommentTypedDataSchemaType-
DeleteCommentWithSigParams-
DeleteCommentWithSigResult-
EditCommentDataEdit comment data schema. This is used as input of the functions.
EditCommentDataParams-
EditCommentDataParamsWithMetadataEntries-
EditCommentParams-
EditCommentResult-
EditCommentTypedDataSchemaType-
EditCommentWithSigParams-
EditCommentWithSigResult-
GetAddApprovalHashData-
GetAddApprovalHashParams-
GetAddApprovalHashResult-
GetChannelManagerParams-
GetCommentIdParams-
GetCommentParams-
GetCommentResult-
GetContractNameParams-
GetContractVersionParams-
GetDeleteCommentHashParams-
GetDomainSeparatorParams-
GetEditCommentHashParams-
GetNonceParams-
GetRemoveApprovalHashParams-
GetRemoveApprovalHashResult-
IsApprovedParams-
Json-
JsonArray-
JsonLiteral-
JsonObject-
MetadataEntryMetadata entry structure that matches the smart contract
MetadataEntryOp-
MetadataRecordJS/SDK/Indexer format for metadata storage
MetadataTypeType representing the supported on-chain serializable types
PostCommentParams-
PostCommentResult-
PostCommentWithSigParams-
PostCommentWithSigResult-
RemoveApprovalTypedDataSchemaType-
ReportCommentTypedDataSchemaType-
RevokeApprovalParams-
RevokeApprovalResult-
RevokeApprovalWithSigParams-
RevokeApprovalWithSigResult-
UpdateChannelContractParams-
UpdateChannelContractResult-

Variables

VariableDescription
ADD_APPROVAL_TYPE-
ADD_COMMENT_TYPE-
AddApprovalTypedDataSchema-
AddCommentTypedDataSchema-
CommentDataSchema-
CommentInputDataSchemaComment input data schema. This is used as input of the functions.
CommentTypeSchema-
CreateCommentDataSchema-
DELETE_COMMENT_TYPE-
deleteCommentDelete a comment as an author
DeleteCommentTypedDataSchema-
deleteCommentWithSigDelete a comment with app signature verification
DOMAIN_NAME-
DOMAIN_VERSION-
EDIT_COMMENT_TYPE-
editCommentEdit a comment as an author
EditCommentDataSchemaEdit comment data schema. This is used as input of the functions.
EditCommentTypedDataSchema-
editCommentWithSigEdit a comment
JsonLiteralSchema-
JsonObjectSchema-
JsonSchema-
METADATA_ENTRY_TYPE-
MetadataArrayOpSchema-
MetadataArraySchema-
MetadataEntryOpSchema-
MetadataEntrySchema-
MetadataTypeValuesConstants object for MetadataType values - provides runtime access to all metadata types
postCommentPosts a comment as an author
postCommentWithSigPosts a comment with author signature verification
REMOVE_APPROVAL_TYPE-
RemoveApprovalTypedDataSchema-
ReplyCommentInputDataSchema-
REPORT_COMMENT_TYPE-
ReportCommentTypedDataSchema-
RootCommentInputDataSchema-

Functions

FunctionDescription
addApprovalApproves an app signer directly as author
addApprovalWithSigAdds an app signer approval with signature verification
convertContractToRecordFormatConverts from contract MetadataEntry array format to JS/SDK Record format Note: This requires knowledge of the original key string and type, which are lost in the contract format. This function attempts to reverse-engineer them from common patterns used in the codebase.
convertRecordToContractFormatConverts from JS/SDK Record format to contract MetadataEntry array format
createApprovalTypedDataCreate the EIP-712 typed data structure for approving comment
createCommentDataCreate the data structure of a comment
createCommentTypedDataCreate the EIP-712 typed data structure for adding comment
createCustomMetadataEntryCreates a metadata entry with a custom type
createDeleteCommentTypedDataCreate the EIP-712 typed data structure for deleting comment
createEditCommentDataCreate the data structure of a comment for editing
createEditCommentTypedDataCreate the EIP-712 typed data structure for editing comment
createKeyTypeMapHelper function to create a key-type mapping for known metadata keys This should be maintained by applications to properly convert from contract format
createMetadataEntriesCreates multiple metadata entries from an object with explicit types
createMetadataEntryCreates a metadata entry from a key-value pair with explicit type specification
createMetadataKeyCreates a metadata key by encoding a string in the format "type key" using abi.encodePacked
createRemoveApprovalTypedDataCreate the EIP-712 typed data structure for removing approval
createReportCommentTypedDataCreate the EIP-712 typed data structure for reporting a comment
decodeAddressValueDecodes an address value from encoded metadata bytes
decodeBoolValueDecodes a boolean value from encoded metadata bytes
decodeBytesValueDecodes a bytes value from encoded metadata bytes
decodeMetadataTypesDecodes metadata types from on-chain metadata entries by reverse-engineering the type information from the encoded key field. Works without requiring prior knowledge of the key-type mappings.
decodeMetadataValueDecodes a metadata entry value based on its type
decodeNumberValueDecodes a number value from encoded metadata bytes
decodeStringValueDecodes a string value from encoded metadata bytes
encodeBoolValueEncodes a boolean value as bytes for metadata
encodeJsonValueEncodes a JSON object as bytes for metadata
encodeNumberValueEncodes a number value as bytes for metadata
encodeStringValueEncodes a string value as bytes for metadata
getAddApprovalHashGets the EIP-712 hash for adding approval
getChannelManagerGets the channel manager contract address
getCommentGet a comment by ID
getCommentIdGet the ID for a comment before it is posted
getContractNameGets the contract name
getContractVersionGets the contract version
getDeleteCommentHashGet the hash for deleting a comment
getDomainSeparatorGets the EIP-712 domain separator
getEditCommentHashGet the hash for editing a comment
getNonceGet the nonce for the author and app signer
getRemoveApprovalHashGets the EIP-712 hash for removing approval
isApprovedChecks if an app signer is approved for an author
parseMetadataFromContractConvenience function to convert metadata from contracts for JS/SDK use
prepareMetadataForContractConvenience function to convert metadata for sending to contracts Handles both Record format and direct MetadataEntry array
revokeApprovalRevokes an app signer approval directly as author
revokeApprovalWithSigRemoves an app signer approval with signature verification
updateChannelContractUpdates the channel manager contract address (only owner)