{
    "Function": "createComment",
    "File": "contracts/libraries/PublishingLogic.sol",
    "Parent Contracts": [],
    "High-Level Calls": [
        "IReferenceModule"
    ],
    "Internal Calls": [
        "_emitCommentCreated",
        "_initPubCollectModule",
        "revert PublicationDoesNotExist()",
        "_initPubReferenceModule"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function createComment(\n        DataTypes.CommentData memory vars,\n        uint256 pubId,\n        mapping(uint256 => DataTypes.ProfileStruct) storage _profileById,\n        mapping(uint256 => mapping(uint256 => DataTypes.PublicationStruct))\n            storage _pubByIdByProfile,\n        mapping(address => bool) storage _collectModuleWhitelisted,\n        mapping(address => bool) storage _referenceModuleWhitelisted\n    ) external {\n        // Validate existence of the pointed publication\n        uint256 pubCount = _profileById[vars.profileIdPointed].pubCount;\n        if (pubCount < vars.pubIdPointed || vars.pubIdPointed == 0)\n            revert Errors.PublicationDoesNotExist();\n\n        _pubByIdByProfile[vars.profileId][pubId].contentURI = vars.contentURI;\n        _pubByIdByProfile[vars.profileId][pubId].profileIdPointed = vars.profileIdPointed;\n        _pubByIdByProfile[vars.profileId][pubId].pubIdPointed = vars.pubIdPointed;\n\n        // Collect Module Initialization\n        bytes memory collectModuleReturnData = _initPubCollectModule(\n            vars.profileId,\n            pubId,\n            vars.collectModule,\n            vars.collectModuleData,\n            _pubByIdByProfile,\n            _collectModuleWhitelisted\n        );\n\n        // Reference module initialization\n        bytes memory referenceModuleReturnData = _initPubReferenceModule(\n            vars.profileId,\n            pubId,\n            vars.referenceModule,\n            vars.referenceModuleData,\n            _pubByIdByProfile,\n            _referenceModuleWhitelisted\n        );\n\n        // Reference module validation\n        address refModule = _pubByIdByProfile[vars.profileIdPointed][vars.pubIdPointed]\n            .referenceModule;\n        if (refModule != address(0)) {\n            IReferenceModule(refModule).processComment(\n                vars.profileId,\n                vars.profileIdPointed,\n                vars.pubIdPointed\n            );\n        }\n\n        // Prevents a stack too deep error\n        _emitCommentCreated(vars, pubId, collectModuleReturnData, referenceModuleReturnData);\n    }"
}