-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logs rewrite #98
base: master
Are you sure you want to change the base?
Logs rewrite #98
Changes from all commits
9d4d90b
4165e34
f0e6738
8622a91
82e06ed
be4c175
4470109
1eb3c98
4fe73a4
10a0708
e22a2ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,6 +228,10 @@ git submodule add [email protected]:distribute-protocol/abis.git frontend/src/abi/b | |
git submodule update --init --recursive | ||
``` | ||
If you receive the error that `'frontend/src/abi/build' already exists in the index` then you can move to the next command | ||
Updating submodules can be achieved easily from the root folder using | ||
``` | ||
git submodule foreach git pull origin master | ||
``` | ||
|
||
*Step 2:* | ||
|
||
|
+1 −1 | build | |
+7 −7 | contracts/HyphaToken.sol | |
+7 −7 | contracts/Project.sol | |
+17 −17 | contracts/ProjectLibrary.sol | |
+16 −17 | contracts/ProjectRegistry.sol | |
+18 −18 | contracts/ReputationRegistry.sol | |
+41 −41 | contracts/TokenRegistry.sol | |
+6 −6 | migrations/3_deploy_contracts.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
let obj = require('./build/contracts/DistributeToken.json') | ||
let obj = require('./build/contracts/HyphaToken.json') | ||
|
||
const DistributeTokenAddress = obj.networks['5777'].address | ||
const HyphaTokenAddress = Object.keys(obj.networks).sort()[Object.keys(obj.networks).length - 1].address | ||
|
||
const DistributeTokenABI = JSON.stringify(obj.abi) | ||
const HyphaTokenABI = JSON.stringify(obj.abi) | ||
|
||
const DistributeTokenBytecode = obj.bytecode | ||
const HyphaTokenBytecode = obj.bytecode | ||
|
||
module.exports = { | ||
DistributeTokenAddress, | ||
DistributeTokenABI, | ||
DistributeTokenBytecode | ||
HyphaTokenAddress, | ||
HyphaTokenABI, | ||
HyphaTokenBytecode | ||
} |
+385 −361 | contracts/AttributeStore.json | |
+1,198 −1,200 | contracts/BytesLib.json | |
+905 −887 | contracts/DLL.json | |
+238 −258 | contracts/Division.json | |
+1,243 −1,247 | contracts/EIP20.json | |
+419 −365 | contracts/EIP20Interface.json | |
+3,405 −3,120 | contracts/HyphaToken.json | |
+325 −327 | contracts/Migrations.json | |
+492 −471 | contracts/Ownable.json | |
+7,104 −6,576 | contracts/PLCRVoting.json | |
+4,175 −3,907 | contracts/Project.json | |
+8,925 −8,101 | contracts/ProjectLibrary.json | |
+9,779 −8,567 | contracts/ProjectRegistry.json | |
+545 −531 | contracts/ProxyFactory.json | |
+8,281 −7,312 | contracts/ReputationRegistry.json | |
+527 −535 | contracts/SafeMath.json | |
+213 −211 | contracts/SpoofedRR.json | |
+2,185 −2,040 | contracts/Task.json | |
+10,766 −9,899 | contracts/TokenRegistry.json |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
let obj = require('./build/contracts/HyphaToken.json') | ||
//This address lookup is broken...the network id will be different based on where it is being deployed, check this before deployment | ||
const HyphaTokenAddress = Object.keys(obj.networks).sort()[Object.keys(obj.networks).length - 1].address | ||
//console.log(Object.keys(obj.networks)) | ||
const HyphaTokenABI = obj.abi | ||
|
||
const HyphaTokenBytecode = obj.bytecode | ||
|
||
module.exports = { | ||
HyphaTokenAddress, | ||
HyphaTokenABI, | ||
HyphaTokenBytecode | ||
} |
+385 −361 | contracts/AttributeStore.json | |
+1,198 −1,200 | contracts/BytesLib.json | |
+905 −887 | contracts/DLL.json | |
+238 −258 | contracts/Division.json | |
+1,243 −1,247 | contracts/EIP20.json | |
+419 −365 | contracts/EIP20Interface.json | |
+3,405 −3,120 | contracts/HyphaToken.json | |
+325 −327 | contracts/Migrations.json | |
+492 −471 | contracts/Ownable.json | |
+7,104 −6,576 | contracts/PLCRVoting.json | |
+4,175 −3,907 | contracts/Project.json | |
+8,925 −8,101 | contracts/ProjectLibrary.json | |
+9,779 −8,567 | contracts/ProjectRegistry.json | |
+545 −531 | contracts/ProxyFactory.json | |
+8,281 −7,312 | contracts/ReputationRegistry.json | |
+527 −535 | contracts/SafeMath.json | |
+213 −211 | contracts/SpoofedRR.json | |
+2,185 −2,040 | contracts/Task.json | |
+10,766 −9,899 | contracts/TokenRegistry.json |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ const User = require('../models/user') | |
const Validation = require('../models/validation') | ||
const Vote = require('../models/vote') | ||
const PrelimTaskList = require('../models/prelimTaskList') | ||
const { VoteRecord } = require('../models/voteRecord') | ||
const _ = require('lodash') | ||
// The resolvers | ||
const resolvers = { | ||
|
@@ -52,19 +51,16 @@ const resolvers = { | |
tasks: (user) => Task.find({claimer: user.id}).then(tasks => tasks), | ||
tokenChanges: (user) => Token.find({userId: user.id}).then(tokens => tokens), | ||
validations: (user) => Validation.find({userId: user.id}).then(validations => validations), | ||
votes: (user) => Vote.find({userId: user.id}).then(votes => votes), | ||
voteRecords: (user) => User.findOne({_id: user.id}).then(userDoc => userDoc.voteRecords) | ||
}, | ||
VoteRecord: { | ||
voter: (vote) => User.findOne({account: vote.voter}).then(user => user), | ||
task: (vote) => Task.findById(vote.task).then(voteRecord => voteRecord) | ||
votes: (user) => Vote.find({voter: user.id}).then(votes => votes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fun fact, you don't need the code after then |
||
}, | ||
|
||
Validation: { | ||
task: (validation) => Task.findById(validation.task).then(task => task) | ||
task: (validation) => Task.findById(validation.task).then(task => task), | ||
project: (validation) => Project.findById(validation.project).then(project => project) | ||
}, | ||
Vote: { | ||
task: (vote) => Task.findById(vote.taskId).then(vote => vote), | ||
user: (vote) => User.findById(vote.userId).then(user => user) | ||
task: (vote) => Task.findById(vote.task).then(task => task), | ||
voter: (vote) => User.findById(vote.voter).then(user => user) | ||
}, | ||
Query: { | ||
network: () => Network.findOne({}).then(status => status), | ||
|
@@ -87,18 +83,19 @@ const resolvers = { | |
verifiedPrelimTaskLists: (_, args) => PrelimTaskList.find({address: args.address.toLowerCase(), verified: true}).then(prelimTaskLists => prelimTaskLists), | ||
userPrelimTaskLists: (_, args) => PrelimTaskList.findOne({submitter: args.account.toLowerCase()}).then(prelimTaskLists => prelimTaskLists), | ||
taskValidations: (_, args) => Project.findOne({address: args.address.toLowerCase()}).then(project => Task.find({project: project.id}).then(task => Validation.find({task: task.id})).then(validations => validations)), | ||
userVotes: (account) => [{}], | ||
userVoteRecords: (_, args) => User.findOne({account: args.account}).then(user => user.voteRecords), | ||
userVotes: (_, args) => User.findOne({account: args.account}).then(user => Vote.find({voter: user.id}).then(votes => votes)), | ||
taskVotes: (address) => [{}], | ||
findFinalTaskHash: (_, args) => PrelimTaskList.findOne({hash: args.topTaskHash, address: args.address.toLowerCase()}).then(prelimTaskList => prelimTaskList), | ||
findTaskByIndex: (_, args) => Project.findOne({address: args.address.toLowerCase()}).then(project => Task.findOne({project: project.id, index: args.index})).then(task => task), | ||
allTasksinProject: (_, args) => Project.findOne({address: args.address.toLowerCase()}).then(project => Task.find({project: project.id})).then(tasks => tasks), | ||
getValidations: (_, args) => Project.findOne({address: args.address.toLowerCase()}).then(project => Task.findOne({project: project.id, index: args.index})).then(task => Validation.find({task: task.id})).then(validations => validations), | ||
getUserValidationsinProject: (_, args) => Validation.find({projAddress: args.address.toLowerCase(), user: args.user.toLowerCase()}).then(validations => validations), | ||
getPrevPollID: (obj, args) => User.findOne({account: args.account}).then((user) => { | ||
let insertIndex = _.sortedIndexBy(user.voteRecords, {amount: args.amount}, (o) => o.amount) | ||
let prevPollID = insertIndex < 1 ? 0 : user.voteRecords[insertIndex - 1].pollID | ||
return prevPollID | ||
getPrevPollID: (obj, args) => User.findOne({account: args.account}).then(user => { | ||
Vote.find({voter: user.id, revealed: false, rescued: false}).sort({amount: 1}).then(votes => { | ||
let insertIndex = _.sortedIndexBy(votes, {amount: args.amount}, (o) => o.amount) | ||
let prevPollID = insertIndex < 1 ? 0 : votes[insertIndex - 1].pollID | ||
return prevPollID | ||
}) | ||
}) | ||
}, | ||
Mutation: { | ||
|
@@ -174,50 +171,28 @@ const resolvers = { | |
} | ||
}) | ||
}, | ||
addVote: (obj, args) => { | ||
User.findOne({account: args.voter}).exec((err, user) => { | ||
if (err) { | ||
console.error(err) | ||
} else { | ||
Project.findOne({address: args.projectAddress}).exec((err, project) => { | ||
if (err) { console.error(err) } | ||
Task.findOne({project: project.id, index: args.taskIndex}).exec((err, task) => { | ||
if (err) { console.error(err) } | ||
let userVoteObj = new VoteRecord({ | ||
_id: new mongoose.Types.ObjectId(), | ||
amount: args.amount, | ||
pollID: args.pollID, | ||
project: args.projectAddress, | ||
revealed: false, | ||
rescued: false, | ||
salt: args.salt, | ||
task: task.id, | ||
type: args.type, | ||
vote: args.vote, | ||
voter: user.id | ||
}) | ||
let index = _.sortedIndexBy(user.voteRecords, userVoteObj, (o) => o.amount) | ||
user.voteRecords.splice(index, 0, userVoteObj) | ||
user.markModified('voteRecords') | ||
user.save(err => { | ||
if (err) return console.log(err) | ||
return userVoteObj | ||
}) | ||
}) | ||
}) | ||
|
||
// userVoteObj.save((err, vote) => { | ||
// if (err) return console.log(err) | ||
// let index = _.sortedIndexBy(user.voteRecords, vote, (o) => o.amount) | ||
// user.voteRecords.splice(index, 0, vote) | ||
// user.markModified('voteRecords') | ||
// user.save((err) => { | ||
// if (err) return console.log(err) | ||
// return vote | ||
// }) | ||
// }) | ||
} | ||
}) | ||
addVote: async (obj, args) => { | ||
try { | ||
const user = await User.findOne({account: args.voter}) | ||
const project = await Project.findOne({account: args.projectAddress}) | ||
const task = await Task.findOne({project: project.id, index: args.taskIndex}) | ||
const vote = await Vote.findOneAndUpdate({ | ||
amount: args.amount, | ||
pollID: args.pollID, | ||
project: project.id, | ||
revealed: false, | ||
rescued: false, | ||
task: task.id, | ||
type: args.type, | ||
voter: user.id | ||
}, { $set: { | ||
salt: args.salt, | ||
vote: args.vote | ||
}}, {upsert: true}) | ||
if (!vote) console.error('vote not added successfully') | ||
} catch (err) { | ||
console.error('Error Adding Vote') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wonder if you want to rethrow here, so it bubbles up to what gets returned by graphql? What does this mutation return? |
||
} | ||
} | ||
// let prelimTaskListSubmitted = new PrelimTaskList({ | ||
// _id: new mongoose.Types.ObjectId(), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about making network id an environment var?