Browse Source

Removed unused contract

develop
Ezerous 6 years ago
parent
commit
d93afb2a42
  1. 1
      app/src/CustomPropTypes.js
  2. 2
      app/src/components/Topic.js
  3. 5
      app/src/containers/LoadingContainer.js
  4. 10
      app/src/utils/orbitUtils.js
  5. 81
      contracts/Posting.sol

1
app/src/CustomPropTypes.js

@ -1,5 +1,6 @@
import PropTypes from 'prop-types';
//TODO: Move this file
const GetTopicResult = PropTypes.PropTypes.shape({
0: PropTypes.string,
1: PropTypes.string,

2
app/src/components/Topic.js

@ -24,8 +24,8 @@ class Topic extends Component {
const { dispatch, topicData, topicSubject, orbitDB } = this.props;
const { askedForReplication } = this.state;
if(!askedForReplication && orbitDB.ipfsInitialized && orbitDB.orbitdb && dispatch && !topicSubject && topicData) {
this.setState({ askedForReplication: true });
dispatch(addPeerDatabase(`/orbitdb/${topicData.value[0]}/topics`));
this.setState({ askedForReplication: true });
}
}

5
app/src/containers/LoadingContainer.js

@ -2,7 +2,6 @@ import React, { Children, Component } from 'react';
import { connect } from 'react-redux';
import ipfs_logo from '../assets/images/ipfs_logo.png';
//TODO: Add OrbitDB Loading thingy
class LoadingContainer extends Component {
render() {
@ -52,7 +51,9 @@ class LoadingContainer extends Component {
<div>
<h1><span role="img" aria-label="Gear"></span></h1>
<p><strong>Initializing contracts...</strong></p>
<p>If this takes too long please make sure they are deployed to the network.</p>
<p>If this takes too long please make sure they are deployed to the network
and you are connected to the correct one.
</p>
</div>
</div>
</main>

10
app/src/utils/orbitUtils.js

@ -13,7 +13,11 @@ function initIPFS() {
store.dispatch({
type: IPFS_INITIALIZED, ipfs
});
console.debug('IPFS initialized.');
ipfs.id(function (error, identity) {
if (error)
console.error(`IPFS id() error: ${error}`);
console.debug(`IPFS initialized with id: ${identity.id}`);
})
});
}
@ -22,7 +26,7 @@ async function createDatabases() {
localStorage.clear(); // Perhaps not needed at all when orbit ids are used in Orbit 0.20.x+
console.debug('Creating databases...');
const ipfs = getIPFS();
const orbitdb = await new OrbitDB(ipfs);
const orbitdb = new OrbitDB(ipfs);
const topicsDB = await orbitdb.keyvalue('topics');
const postsDB = await orbitdb.keyvalue('posts');
store.dispatch(
@ -55,7 +59,7 @@ async function loadDatabases(identityId, identityPublicKey, identityPrivateKey,
}));
const ipfs = getIPFS();
const orbitdb = await new OrbitDB(ipfs, directory,
const orbitdb = new OrbitDB(ipfs, directory,
{
peerId: orbitId, keystore
});

81
contracts/Posting.sol

@ -1,81 +0,0 @@
pragma solidity >=0.5.6 <0.6.0;
contract Posting {
address forumContractAddress;
function setForumContractAddress() public{
require(forumContractAddress==address(0));
forumContractAddress = msg.sender;
}
struct Topic {
uint topicID;
address author;
uint timestamp;
uint[] postIDs;
}
struct Post {
uint postID;
address author;
uint timestamp;
uint topicID;
}
uint numTopics; // Total number of topics
uint numPosts; // Total number of posts
mapping (uint => Topic) topics;
mapping (uint => Post) posts;
function createTopic(address author) public returns (uint, uint) {
require(msg.sender==forumContractAddress);
//Creates topic
uint topicID = numTopics++;
topics[topicID] = Topic(topicID, author, block.timestamp, new uint[](0));
//Adds first post to topic
uint postID = numPosts++;
posts[postID] = Post(postID, author, block.timestamp, topicID);
topics[topicID].postIDs.push(postID);
return (topicID, postID);
}
function createPost(uint topicID, address author) public returns (uint) {
require(msg.sender==forumContractAddress);
require(topicID<numTopics); // Only allow posting to a topic that exists
uint postID = numPosts++;
posts[postID] = Post(postID, author, block.timestamp, topicID);
topics[topicID].postIDs.push(postID);
return postID;
}
function getNumberOfTopics() public view returns (uint) {
return numTopics;
}
function getTopicInfo(uint topicID) public view returns (address, uint, uint[] memory) {
require(topicID<numTopics);
return (topics[topicID].author,
topics[topicID].timestamp,
topics[topicID].postIDs
);
}
function getTopicPosts(uint topicID) public view returns (uint[] memory) {
require(topicID<numTopics); // Topic should exist
return topics[topicID].postIDs;
}
function getPostInfo(uint postID) public view returns (address, uint, uint) {
require(postID<numPosts);
return (
posts[postID].author,
posts[postID].timestamp,
posts[postID].topicID
);
}
}
Loading…
Cancel
Save