This commit is contained in:
Jordi Baylina 2017-07-11 04:01:00 -07:00
parent 849f9e5c96
commit 978dbae46d
No known key found for this signature in database
GPG Key ID: 7480C80C1BE43112
4 changed files with 108 additions and 26 deletions

View File

@ -38,7 +38,10 @@
// react
"react/prefer-es6-class": 0,
"react/jsx-filename-extension": 0,
"react/jsx-indent": [ 2, 4 ]
"react/jsx-indent": [ 2, 4 ],
"jsx-a11y/href-no-hash": "off",
"jsx-a11y/anchor-is-valid": ["warn", { "aspects": ["invalidHref"] }]
},
"globals": {
"artifacts": true,

View File

@ -2,33 +2,112 @@ const LiquidPledgingAbi = require("../build/contracts/LiquidPledging.json").abi;
module.exports = class LiquidPledging {
constructor(web3, address) {
this.notes = [];
this.managers = [];
this.web3 = web3;
this.address = address;
this.notes = [];
this.managers = [];
}
getDonorInfo(idDonor) {
const st = {};
return st;
getFullState(cb) {
const liquidPledging = this.web3.eth.contract(LiquidPledgingAbi).at(this.address);
}
}
/*
managers = []
generateDonorsState() {
const donorsState = [];
const getDonor = (idNote) => {
let note = this.notes[ idNote ];
while (note.oldNode) note = this.notes[ idNote ];
return note.owner;
};
donors = [
"donor"/idDonor(d1,d2)/"NotAssigned"/idDelegate1/idDelegate2
/"PreAssigned"/idProject1
/"Assigned"/idProject1/idProject2
/"Spended"/idProject1/idProject2
const addDonor = (_list, idDonor) => {
const list = _list;
if (!list[ idDonor ]) {
list[ idDonor ] = {
idDonor,
notAssigned: {
notes: [],
delegates: [],
},
precommitedProjects: [],
commitedProjects: [],
};
}
};
donor(d1,d2)/project1(d3,d4)/idProject2(d5, d6)/["Paying,Paid"]
["Preassigned: IDTIME"]
/"Assigned"/donor(d1,d2)/project1(d3,d4)
/"Spent"/idProject1/idProject2/idProject(da,db)
const addDelegate = (_list, idDelegate) => {
const list = _list;
if (!list[ idDelegate ]) {
list[ idDelegate ] = {
idDelegate,
name: this.managers[ idDelegate ].name,
notes: [],
delegtes: [],
};
}
};
]
const addProject = (_list, idProject) => {
const list = _list;
if (!list[ idProject ]) {
list[ idProject ] = {
idProject,
notes: [],
commitedProjects: [],
name: this.managers[ idProject ].name,
commitTime: this.managers[ idProject ].commitTime,
owner: this.managers[ idProject ].owner,
reviewer: this.managers[ idProject ].reviewer,
};
}
};
console.log(JSON.stringify(LiquidPledgingAbi));
*/
const addDelegateNote = (stDonor, idNote) => {
const note = this.notes[ idNote ];
stDonor.notAssigned.notes.push(idNote);
let list = stDonor.notAssigned.delegates;
for (let i = 0; i < note.delegationChain.length; i += 1) {
const idDelegate = note.delegationChain[ i ];
addDelegate(list, idDelegate);
list = list[ idDelegate ].delegates;
}
};
const addProjectNote = (stDonor, idNote) => {
const note = this.notes[ idNote ];
const projectList = [];
let n = note;
while (n.oldNode) {
projectList.unshift(n.owner);
n = this.notes[ n.oldNode ];
}
let list = stDonor.commitedProjects;
for (let j = 0; j < projectList.length; j += 1) {
addProject(list, projectList[ j ]);
list[ projectList[ j ] ].notes.push(idNote);
list = list[ projectList[ j ] ].commitedProjects;
}
};
for (let i = 0; i < this.notes; i += 1) {
const idNote = this.notes[ i ];
const idDonor = getDonor(idNote);
addDonor(donorsState, idDonor);
const stDonor = donorsState[ idDonor ];
const note = this.notes[ idNote ];
if ((note.owner === idDonor) && (note.precommitedProject === 0)) {
addDelegateNote(stDonor, idNote);
} else if ((note.owner === idDonor) && (note.precommitedProject === 0)) {
addProject(stDonor.precommitedProjects, note.precommitedProject);
stDonor.precommitedProjects[ note.precommitedProject ].notes.push(idNote);
} else {
addProjectNote(stDonor, idNote);
}
}
this.donorsState = donorsState;
}
};

6
package-lock.json generated
View File

@ -3191,9 +3191,9 @@
}
},
"eslint-plugin-jsx-a11y": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.0.0.tgz",
"integrity": "sha1-1c3Wj2ZaiVQKVd3A2JjK+AypSsU=",
"version": "6.0.2",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsx-a11y/-/eslint-plugin-jsx-a11y-6.0.2.tgz",
"integrity": "sha1-ZZJ3p1iwNsMFp+ShMFfDAc075z8=",
"dev": true
},
"eslint-plugin-promise": {

View File

@ -32,7 +32,7 @@
"bignumber.js": "^4.0.2",
"eslint-config-airbnb": "^15.0.1",
"eslint-plugin-import": "^2.6.0",
"eslint-plugin-jsx-a11y": "^6.0.0",
"eslint-plugin-jsx-a11y": "^6.0.2",
"eslint-plugin-react": "^7.1.0",
"ethereumjs-testrpc": "^3.0.5",
"random-bytes": "^1.0.0",