Governance: Reputation Concept Implemented
This commit is contained in:
1 parent
7571f8daec
commit
1cd90530e8
6 files changed
+153
-86
No files matched your search
@@ -59,7 +59,7 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
distributeProgram(program)
|
||||
distributeProgram(program, userProfile)
|
||||
}
|
||||
|
||||
/* Bonus Calculation is here */
|
||||
@@ -181,24 +181,25 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
}
|
||||
}
|
||||
|
||||
function distributeProgram(programNode) {
|
||||
function distributeProgram(programNode, userProfile) {
|
||||
if (programNode.payload === undefined) { return }
|
||||
/*
|
||||
Transform Token Power into Votes
|
||||
*/
|
||||
let votes = programNode.payload.tokenPower
|
||||
let votes = programNode.payload.tokenPower + userProfile.payload.reputation
|
||||
/*
|
||||
Set this initial votes as own power
|
||||
*/
|
||||
programNode.payload.votingProgram.ownPower = votes
|
||||
distributeProgramPower(programNode, programNode, votes, undefined, 0)
|
||||
distributeProgramPower(programNode, programNode, votes, undefined, 0, userProfile)
|
||||
|
||||
function distributeProgramPower(
|
||||
currentProgramNode,
|
||||
node,
|
||||
votes,
|
||||
percentage,
|
||||
generation
|
||||
generation,
|
||||
userProfile
|
||||
) {
|
||||
if (generation >= MAX_GENERATIONS) {
|
||||
return
|
||||
@@ -212,7 +213,7 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
if (node.type === 'Voting Program') {
|
||||
node.payload.votingProgram.incomingPower = node.payload.votingProgram.votes - node.payload.votingProgram.ownPower
|
||||
}
|
||||
drawVotes(node, node.payload.votingProgram.votes, percentage)
|
||||
drawVotes(node, node.payload.votingProgram.votes, percentage, userProfile)
|
||||
/*
|
||||
When we reach certain node types, we will halt the distribution, because these are targets for
|
||||
voting power.
|
||||
@@ -240,7 +241,8 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
node.payload.referenceParent,
|
||||
votes / 10,
|
||||
undefined,
|
||||
generation + 1
|
||||
generation + 1,
|
||||
userProfile
|
||||
)
|
||||
}
|
||||
return
|
||||
@@ -254,7 +256,8 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
program,
|
||||
votes,
|
||||
undefined,
|
||||
generation
|
||||
generation,
|
||||
userProfile
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -275,7 +278,8 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
node.payload.referenceParent,
|
||||
votes,
|
||||
undefined,
|
||||
generation
|
||||
generation,
|
||||
userProfile
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -357,7 +361,8 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
childNode,
|
||||
votes * percentage / 100,
|
||||
percentage,
|
||||
generation
|
||||
generation,
|
||||
userProfile
|
||||
)
|
||||
}
|
||||
break
|
||||
@@ -377,7 +382,8 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
childNode,
|
||||
votes * percentage / 100,
|
||||
percentage,
|
||||
generation
|
||||
generation,
|
||||
userProfile
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -389,7 +395,7 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
}
|
||||
}
|
||||
|
||||
function drawVotes(node, votes, percentage) {
|
||||
function drawVotes(node, votes, percentage, userProfile) {
|
||||
|
||||
if (node.payload !== undefined) {
|
||||
|
||||
@@ -397,7 +403,7 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
return
|
||||
}
|
||||
if (node.type === 'Voting Program') {
|
||||
drawProgram(node)
|
||||
drawProgram(node, userProfile)
|
||||
|
||||
if (percentage !== undefined) {
|
||||
node.payload.uiObject.setPercentage(percentage.toFixed(2))
|
||||
@@ -447,7 +453,7 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
}
|
||||
|
||||
const votesText = parseFloat(votes.toFixed(0)).toLocaleString('en') + ' ' + voteType
|
||||
|
||||
|
||||
node.payload.uiObject.valueAngleOffset = 0
|
||||
node.payload.uiObject.valueAtAngle = true
|
||||
|
||||
@@ -482,20 +488,21 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
}
|
||||
}
|
||||
|
||||
function drawProgram(node) {
|
||||
function drawProgram(node, userProfile) {
|
||||
if (node.payload === undefined) { return }
|
||||
if (node.payload.votingProgram === undefined) { return }
|
||||
if (node.payload.votingProgram.ownPower === undefined) { return }
|
||||
if (node.payload.votingProgram.incomingPower === undefined) { return }
|
||||
if (userProfile.payload.reputation === undefined) { return }
|
||||
|
||||
const ownPowerText = parseFloat(node.payload.votingProgram.ownPower.toFixed(0)).toLocaleString('en')
|
||||
const ownPowerText = parseFloat((node.payload.votingProgram.ownPower - userProfile.payload.reputation).toFixed(0)).toLocaleString('en')
|
||||
const incomingPowerText = parseFloat(node.payload.votingProgram.incomingPower.toFixed(0)).toLocaleString('en')
|
||||
const reputationPowerText = parseFloat(userProfile.payload.reputation.toFixed(0)).toLocaleString('en')
|
||||
|
||||
node.payload.uiObject.statusAngleOffset = 0
|
||||
node.payload.uiObject.statusAtAngle = false
|
||||
|
||||
node.payload.uiObject.setStatus(ownPowerText + ' Own Power' + ' + ' + incomingPowerText + ' Incoming Voting Power')
|
||||
|
||||
node.payload.uiObject.setStatus(ownPowerText + ' Own Power' + ' + ' + incomingPowerText + ' Incoming Voting Power' + ' + ' + reputationPowerText + ' Reputation Power')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -517,7 +524,7 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
) {
|
||||
originNode.name = destinationNode.name + ' ' + destinationNode.type + ' ' + ' Vote'
|
||||
} else {
|
||||
originNode.name = destinationNode.name
|
||||
originNode.name = destinationNode.name
|
||||
}
|
||||
|
||||
let schemaDocument = getSchemaDocument(destinationNode)
|
||||
|
||||
Reference in new issue
Block a user