Code removal for test run

This commit is contained in:
emizzle 2018-07-18 12:05:40 +02:00
parent 263e9fb041
commit 68a6bae9cf
5 changed files with 53 additions and 51 deletions

View File

@ -51,9 +51,9 @@ class CreateUser extends Component {
//const result = await createAccount.send({ from: web3.eth.defaultAccount, gas: gasEstimate + 1000 });
// check result status. if status is false or '0x0', show user the tx details to debug error
if (result.status && !Boolean(result.status.toString().replace('0x', ''))) { // possible result values: '0x0', '0x1', or false, true
return this.setState({ isLoading: false, error: 'Error executing transaction, transaction details: ' + JSON.stringify(result) });
}
// if (result.status && !Boolean(result.status.toString().replace('0x', ''))) { // possible result values: '0x0', '0x1', or false, true
// return this.setState({ isLoading: false, error: 'Error executing transaction, transaction details: ' + JSON.stringify(result) });
// }
// Completed of async action, set loading state back
this.setState({ isLoading: false });

View File

@ -50,11 +50,11 @@ class DoTweet extends Component{
try{
// estimate gas before sending tweet transaction
const gasEstimate = await tweet.estimateGas({ from: web3.eth.defaultAccount, gas: 10000000000 });
//const gasEstimate = await tweet.estimateGas({ from: web3.eth.defaultAccount, gas: 10000000000 });
// send the tweet transaction plus a little extra gas in case the contract state
// has changed since we've done our gas estimate
await tweet.send({ from: web3.eth.defaultAccount, gas: gasEstimate + 1000 });
//await tweet.send({ from: web3.eth.defaultAccount, gas: gasEstimate + 1000 });
// remove loading state
this.setState({ isLoading: false });

View File

@ -53,20 +53,20 @@ class UpdateUser extends Component {
const { account, user } = this.props;
const { description } = this.state;
const editAccount = DTwitter.methods.editAccount(web3.utils.keccak256(user.username), description, hash);
//const editAccount = DTwitter.methods.editAccount(web3.utils.keccak256(user.username), description, hash);
// get a gas estimate for the transaction with the input username
// and description
const gasEstimate = await editAccount.estimateGas({ from: web3.eth.defaultAccount, gas: 10000000000 });
//const gasEstimate = await editAccount.estimateGas({ from: web3.eth.defaultAccount, gas: 10000000000 });
try {
// send the transaction with our gas estimate (plus a little bit more in case the contract)
// state has changed since we got our estimate
const result = await editAccount.send({ from: web3.eth.defaultAccount, gas: gasEstimate + 1000 });
//const result = await editAccount.send({ from: web3.eth.defaultAccount, gas: gasEstimate + 1000 });
if (result.status && !Boolean(result.status.toString().replace('0x', ''))) {
return this.setState({ isLoading: false, formState: 'error', formUpdated: false, error: 'Error executing transaction, transaction details: ' + JSON.stringify(result) });
}
// if (result.status && !Boolean(result.status.toString().replace('0x', ''))) {
// return this.setState({ isLoading: false, formState: 'error', formUpdated: false, error: 'Error executing transaction, transaction details: ' + JSON.stringify(result) });
// }
// stop loading state, and render the form as successful
this.setState({ isLoading: false, formState: 'success', formUpdated: false });

View File

@ -36,12 +36,13 @@ class UserTweets extends Component {
*/
_getUserDetails = async(username) => {
// get user details and update state
let user = await DTwitter.methods.users(web3.utils.keccak256(username)).call();
//let user = await DTwitter.methods.users(web3.utils.keccak256(username)).call();
// update picture url for ipfs
user.picture = user.picture.length > 0 ? EmbarkJS.Storage.getUrl(user.picture) : imgAvatar;
// TODO: update to Date.js
user.creationDate = this._formatDate(user.creationDate);
//user.picture = user.picture.length > 0 ? EmbarkJS.Storage.getUrl(user.picture) : imgAvatar;
// format the user.creationDate for display
//user.creationDate = this._formatDate(user.creationDate);
this.setState({user: user});
}
@ -55,26 +56,27 @@ class UserTweets extends Component {
* @returns {null}
*/
_subscribeToNewTweetEvent(username){
this.event = DTwitter.events.NewTweet({
filter: {_from: web3.utils.keccak256(username)},
fromBlock: 1
}, (err, event) => {
if (err){
this.props.onError(err, 'UserTweets._subscribeToNewTweetEvent');
}
})
.on('data', (event) => {
let tweets = this.state.tweets;
tweets.push({
content: event.returnValues.tweet,
// TODO: update to Date.js
time: this._formatDate(event.returnValues.time)
});
this.setState({tweets: tweets});
})
.on('error', function(error){
this.props.onError(err, 'UserTweets._subscribeToNewTweetEvent');
});
// this.event = DTwitter.events.NewTweet({
// filter: {_from: web3.utils.keccak256(username)},
// fromBlock: 1
// }, (err, event) => {
// if (err){
// this.props.onError(err, 'UserTweets._subscribeToNewTweetEvent');
// }
// })
// .on('data', (event) => {
// let tweets = this.state.tweets;
// tweets.push({
// content: event.returnValues.tweet,
// time: this._formatDate(event.returnValues.time)
// });
// this.setState({tweets: tweets});
// })
// .on('error', function(error){
// this.props.onError(err, 'UserTweets._subscribeToNewTweetEvent');
// });
}
/**

View File

@ -74,15 +74,15 @@ contract DTwitter {
// reject if sending adddress already created a user
require(owners[msg.sender] == 0);
// add a user to the users mapping and populate details
users[usernameHash].creationDate = now;
users[usernameHash].owner = msg.sender;
users[usernameHash].username = username;
users[usernameHash].description = description;
// add a user to the users mapping and populate details (creationDate, owner, username, description)
// users[usernameHash].creationDate = now;
// users[usernameHash].owner = msg.sender;
// users[usernameHash].username = username;
// users[usernameHash].description = description;
// add entry to our owners mapping so we can retrieve
// user by their addres
owners[msg.sender] = usernameHash;
// owners[msg.sender] = usernameHash;
}
/**
@ -99,13 +99,13 @@ contract DTwitter {
require(users[usernameHash].owner == msg.sender);
// update the description (could be empty)
users[usernameHash].description = description;
//users[usernameHash].description = description;
// only update the user's picture if the hash passed in is
// not empty or null (essentially disallows deletions)
if (bytes(pictureHash).length > 0) {
users[usernameHash].picture = pictureHash;
}
// if (bytes(pictureHash).length > 0) {
// users[usernameHash].picture = pictureHash;
// }
}
/**
@ -138,17 +138,17 @@ contract DTwitter {
// ensure the retrieved user is indeed the sender
require(users[usernameHash].owner == msg.sender);
// get our user
User storage user = users[usernameHash];
// get our user from the usernameHash
//User storage user = users[usernameHash];
// get our new tweet index
uint tweetIndex = user.tweets.length++;
//uint tweetIndex = user.tweets.length++;
// update the user's tweets
user.tweets[tweetIndex] = content;
// update the user's tweets at the tweet index
//user.tweets[tweetIndex] = content;
// emit the tweet event and notify the listeners
emit NewTweet(usernameHash, content, now);
//emit NewTweet(usernameHash, content, now);
}
}