pragma solidity >=0.4.22 <0.7.0; import "./uBloggerRegistry.sol"; contract uBloggerPost { address uBloggerRegistryLocation; address owner; struct Post { uint timestamp; string postData; } mapping (uint => Post) public posts; uint postNumber; constructor () public { owner = msg.sender; uBloggerRegistryLocation = 0x5c22A3e8648A43d5731Da3ED79f5e3E9ba37bd93; } function createPost(string memory _post) public returns (int result, uint _postID){ uBloggerRegistry registry = uBloggerRegistry(uBloggerRegistryLocation); string memory _accountName = registry.getAccountName(msg.sender); if (bytes(_accountName).length == 0){ result = -1; } else if (owner != msg.sender){ result = -2; } else if (bytes(_post).length >= 160) { result = -3; } else { posts[postNumber].timestamp = now; posts[postNumber].postData = _post; postNumber++; result = 0; // Success _postID = postNumber - 1; } } function getPost(uint _postID) public view returns (uint _timestamp, string memory _postData) { _timestamp = posts[_postID].timestamp; _postData = posts[_postID].postData; } function getTotalPosts() public view returns (uint _postNumber) { _postNumber = postNumber; } /*function verifyOwner() public view returns(int result, string memory _accountName){ uBloggerRegistry registry = uBloggerRegistry(uBloggerRegistryLocation); _accountName = registry.getAccountName(msg.sender); if (bytes(_accountName).length > 0) { result = 0; } else { result = -1; } }*/ }