Merge pull request #1221 from Luis-Fernando-Molina/develop
Contribution: Token Power Switch Made Recursive Descendants Fixed
This commit is contained in:
11 files changed
+3003
-2837
No files matched your search
@@ -16,7 +16,7 @@ function newFoundationsUtilitiesBranches() {
|
||||
the array, including the children of the nodes added to the result array.
|
||||
*/
|
||||
if (node === undefined) { return }
|
||||
let resultArray = []
|
||||
let resultArray = []
|
||||
scanNodeBranch(node)
|
||||
return resultArray
|
||||
|
||||
@@ -48,6 +48,7 @@ function newFoundationsUtilitiesBranches() {
|
||||
break
|
||||
case 'array': {
|
||||
let startingNodePropertyArray = startingNode[property.name]
|
||||
if (startingNodePropertyArray === undefined) { continue }
|
||||
for (let m = 0; m < startingNodePropertyArray.length; m++) {
|
||||
scanNodeBranch(startingNodePropertyArray[m])
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -8,6 +8,13 @@
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionProject": "Foundations",
|
||||
"actionFunction": "payload.executeAction",
|
||||
"label": "Add Token Power Switch",
|
||||
"relatedUiObject": "Token Power Switch"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"actionProject": "Foundations",
|
||||
@@ -95,47 +102,53 @@
|
||||
},
|
||||
"propertyNameAtParent": "tokenPowerSwitch",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "tokenPowerSwitch",
|
||||
"type": "array",
|
||||
"childType": "Token Power Switch",
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "referralProgram",
|
||||
"type": "node",
|
||||
"childType": "Referral Program",
|
||||
"autoAdd": true
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "supportProgram",
|
||||
"type": "node",
|
||||
"childType": "Support Program",
|
||||
"autoAdd": true
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "mentorshipProgram",
|
||||
"type": "node",
|
||||
"childType": "Mentorship Program",
|
||||
"autoAdd": true
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "claimsProgram",
|
||||
"type": "node",
|
||||
"childType": "Claims Program",
|
||||
"autoAdd": true
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "votingProgram",
|
||||
"type": "node",
|
||||
"childType": "Voting Program",
|
||||
"autoAdd": true
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "stackingProgram",
|
||||
"type": "node",
|
||||
"childType": "Staking Program",
|
||||
"autoAdd": true
|
||||
"autoAdd": false
|
||||
},
|
||||
{
|
||||
"name": "delegationProgram",
|
||||
"type": "node",
|
||||
"childType": "Delegation Program",
|
||||
"autoAdd": true
|
||||
"autoAdd": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -36,10 +36,11 @@ function newGovernanceFunctionLibraryClaimsProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.claimsProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.claimsProgram.payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Claims Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
resetProgram(userProfile.tokenPowerSwitch.claimsProgram)
|
||||
resetProgram(program)
|
||||
}
|
||||
|
||||
/* Claim Count Follows */
|
||||
@@ -47,14 +48,16 @@ function newGovernanceFunctionLibraryClaimsProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
if (userProfile.payload === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.claimsProgram === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Claims Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
userProfile.payload.claimsProgram = {
|
||||
awarded: {
|
||||
tokens: 0
|
||||
},
|
||||
count: 0
|
||||
}
|
||||
countProgram(userProfile.tokenPowerSwitch.claimsProgram)
|
||||
countProgram(program)
|
||||
}
|
||||
|
||||
/* Claim Distribution Follows */
|
||||
@@ -62,8 +65,10 @@ function newGovernanceFunctionLibraryClaimsProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
if (userProfile.payload === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.claimsProgram === undefined) { continue }
|
||||
distributeProgram(userProfile.tokenPowerSwitch.claimsProgram)
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Claims Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
distributeProgram(program)
|
||||
}
|
||||
|
||||
/* Claim Calculation Follows */
|
||||
@@ -71,8 +76,10 @@ function newGovernanceFunctionLibraryClaimsProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
if (userProfile.payload === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.claimsProgram === undefined) { continue }
|
||||
calculateProgram(userProfile.tokenPowerSwitch.claimsProgram)
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Claims Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
calculateProgram(program)
|
||||
}
|
||||
|
||||
function resetClaims(node) {
|
||||
|
||||
@@ -24,21 +24,23 @@ function newGovernanceFunctionLibraryDelegationProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.delegationProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.delegationProgram.payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Delegation Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
resetProgram(userProfile.tokenPowerSwitch.delegationProgram)
|
||||
resetProgram(program)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.delegationProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.delegationProgram.payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Delegation Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
userProfile.tokenPowerSwitch.delegationProgram.payload.delegationProgram.programPower = userProfile.tokenPowerSwitch.delegationProgram.payload.tokenPower
|
||||
program.payload.delegationProgram.programPower = program.payload.tokenPower
|
||||
|
||||
distributeProgram(userProfile.tokenPowerSwitch.delegationProgram)
|
||||
distributeProgram(program)
|
||||
}
|
||||
|
||||
function resetProgram(node) {
|
||||
|
||||
@@ -28,39 +28,43 @@ function newGovernanceFunctionLibraryStackingProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram.payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Staking Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
resetProgram(userProfile.tokenPowerSwitch.stackingProgram)
|
||||
resetProgram(program)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram.payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Staking Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
validateProgram(userProfile.tokenPowerSwitch.stackingProgram)
|
||||
validateProgram(program, userProfile)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram.payload === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram.payload.stackingProgram.isActive === false) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Staking Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
if (program.payload.stackingProgram.isActive === false) { continue }
|
||||
|
||||
distributeProgram(userProfile.tokenPowerSwitch.stackingProgram)
|
||||
distributeProgram(program)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram.payload === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.stackingProgram.payload.stackingProgram.isActive === false) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Staking Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
if (program.payload.stackingProgram.isActive === false) { continue }
|
||||
|
||||
calculateProgram(userProfile.tokenPowerSwitch.stackingProgram)
|
||||
calculateProgram(program)
|
||||
}
|
||||
|
||||
function resetProgram(node) {
|
||||
@@ -79,17 +83,17 @@ function newGovernanceFunctionLibraryStackingProgram() {
|
||||
}
|
||||
}
|
||||
|
||||
function validateProgram(node) {
|
||||
function validateProgram(node, userProfile) {
|
||||
/*
|
||||
This program is not going to run unless the Profile has Tokens, and for
|
||||
that users needs to execute the setup procedure of signing their Github
|
||||
username with their private key.
|
||||
*/
|
||||
if (
|
||||
node.payload.parentNode.payload.parentNode.payload.blockchainTokens === undefined
|
||||
userProfile.payload.blockchainTokens === undefined
|
||||
) {
|
||||
node.payload.stackingProgram.isActive = false
|
||||
node.payload.parentNode.payload.parentNode.payload.uiObject.setErrorMessage("You need to setup this profile with the Profile Constructor, to access the Token Power of your account at the Blockchain.")
|
||||
userProfile.payload.uiObject.setErrorMessage("You need to setup this profile with the Profile Constructor, to access the Token Power of your account at the Blockchain.")
|
||||
return
|
||||
}
|
||||
node.payload.stackingProgram.isActive = true
|
||||
|
||||
@@ -82,19 +82,6 @@ function newGovernanceFunctionLibraryTokenPower() {
|
||||
userProfile.payload.uiObject.setErrorMessage("You need to have a Token Power Switch child node.")
|
||||
return
|
||||
}
|
||||
if (userProfile.tokenPowerSwitch.referralProgram === undefined) {
|
||||
userProfile.tokenPowerSwitch.payload.uiObject.setErrorMessage("You need to have a Referral Program child node.")
|
||||
return
|
||||
}
|
||||
if (userProfile.tokenPowerSwitch.mentorshipProgram === undefined) {
|
||||
userProfile.tokenPowerSwitch.payload.uiObject.setErrorMessage("You need to have a Mentorship Program child node.")
|
||||
return
|
||||
}
|
||||
if (userProfile.tokenPowerSwitch.supportProgram === undefined) {
|
||||
userProfile.tokenPowerSwitch.payload.uiObject.setErrorMessage("You need to have a Spupport Program child node.")
|
||||
return
|
||||
}
|
||||
|
||||
distributeTokenPower(userProfile, tokenPower)
|
||||
}
|
||||
|
||||
|
||||
@@ -52,21 +52,23 @@ function newGovernanceFunctionLibraryVotingProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.votingProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.votingProgram.payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Voting Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
resetVotes(userProfile.tokenPowerSwitch.votingProgram)
|
||||
resetVotes(program)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.votingProgram === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch.votingProgram.payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, "Voting Program")
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
userProfile.tokenPowerSwitch.votingProgram.payload.votingProgram.votes = userProfile.tokenPowerSwitch.votingProgram.payload.tokenPower
|
||||
program.payload.votingProgram.votes = program.payload.tokenPower
|
||||
|
||||
distributeProgram(userProfile.tokenPowerSwitch.votingProgram)
|
||||
distributeProgram(program)
|
||||
}
|
||||
|
||||
function resetVotes(node) {
|
||||
|
||||
@@ -42,39 +42,43 @@ function newFoundationsUtilitiesDecendentProgram() {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programNodeType)
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
resetProgram(userProfile.tokenPowerSwitch[programPropertyName])
|
||||
resetProgram(program)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programNodeType)
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
|
||||
validateProgram(userProfile.tokenPowerSwitch[programPropertyName])
|
||||
validateProgram(program, userProfile)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName].payload[programPropertyName].isActive === false) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programNodeType)
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
if (program.payload[programPropertyName].isActive === false) { continue }
|
||||
|
||||
distributeProgram(userProfile.tokenPowerSwitch[programPropertyName])
|
||||
distributeProgram(program)
|
||||
}
|
||||
for (let i = 0; i < userProfiles.length; i++) {
|
||||
let userProfile = userProfiles[i]
|
||||
|
||||
if (userProfile.tokenPowerSwitch === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue }
|
||||
if (userProfile.tokenPowerSwitch[programPropertyName].payload[programPropertyName].isActive === false) { continue }
|
||||
let program = UI.projects.governance.utilities.validations.onlyOneProgram(userProfile, programNodeType)
|
||||
if (program === undefined) { continue }
|
||||
if (program.payload === undefined) { continue }
|
||||
if (program.payload[programPropertyName].isActive === false) { continue }
|
||||
|
||||
calculateProgram(userProfile.tokenPowerSwitch[programPropertyName])
|
||||
calculateProgram(program)
|
||||
}
|
||||
|
||||
function resetProgram(node) {
|
||||
@@ -123,17 +127,17 @@ function newFoundationsUtilitiesDecendentProgram() {
|
||||
}
|
||||
}
|
||||
|
||||
function validateProgram(node) {
|
||||
function validateProgram(node, userProfile) {
|
||||
/*
|
||||
This program is not going to run unless the Profile has Tokens, and for
|
||||
that users needs to execute the setup procedure of signing their Github
|
||||
username with their private key.
|
||||
*/
|
||||
if (
|
||||
node.payload.parentNode.payload.parentNode.payload.blockchainTokens === undefined
|
||||
userProfile.payload.blockchainTokens === undefined
|
||||
) {
|
||||
node.payload[programPropertyName].isActive = false
|
||||
node.payload.parentNode.payload.parentNode.payload.uiObject.setErrorMessage("You need to setup this profile with the Profile Constructor, to access the Token Power of your account at the Blockchain.")
|
||||
userProfile.payload.uiObject.setErrorMessage("You need to setup this profile with the Profile Constructor, to access the Token Power of your account at the Blockchain.")
|
||||
return
|
||||
}
|
||||
/*
|
||||
@@ -143,7 +147,7 @@ function newFoundationsUtilitiesDecendentProgram() {
|
||||
at the top of the program pyramid.)
|
||||
*/
|
||||
if (
|
||||
node.payload.parentNode.payload.parentNode.payload.blockchainTokens < 1000000 &&
|
||||
userProfile.payload.blockchainTokens < 1000000 &&
|
||||
(node[usersArrayPropertyName] === undefined || hasUsersDefined(node[usersArrayPropertyName]) === false)
|
||||
) {
|
||||
node.payload[programPropertyName].isActive = false
|
||||
@@ -316,7 +320,7 @@ function newFoundationsUtilitiesDecendentProgram() {
|
||||
function drawUserNode(node, percentage) {
|
||||
if (node.payload !== undefined) {
|
||||
|
||||
const outgoingPowerText = parseFloat(node.payload[programPropertyName].outgoingPower.toFixed(2)).toLocaleString('en')
|
||||
const outgoingPowerText = parseFloat(node.payload[programPropertyName].outgoingPower.toFixed(2)).toLocaleString('en')
|
||||
|
||||
node.payload.uiObject.valueAngleOffset = 180
|
||||
node.payload.uiObject.valueAtAngle = true
|
||||
@@ -344,7 +348,7 @@ function newFoundationsUtilitiesDecendentProgram() {
|
||||
node.payload.uiObject.statusAngleOffset = 0
|
||||
node.payload.uiObject.statusAtAngle = false
|
||||
|
||||
node.payload.uiObject.setStatus(ownPowerText + ' Own Power' + ' - ' + incomingPowerText + ' Incoming Power' + '')
|
||||
node.payload.uiObject.setStatus(ownPowerText + ' Own Power' + ' - ' + incomingPowerText + ' Incoming Power' + '')
|
||||
}
|
||||
if (node.tokensAwarded !== undefined && node.tokensAwarded.payload !== undefined) {
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
function newFoundationsUtilitiesValidations() {
|
||||
let thisObject = {
|
||||
onlyOneProgram: onlyOneProgram
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function onlyOneProgram(userProfile, programNodeType) {
|
||||
/*
|
||||
Find all the nodes representing the current program.
|
||||
*/
|
||||
let programs = UI.projects.foundations.utilities.branches.nodeBranchToArray(userProfile, programNodeType)
|
||||
if (programs !== undefined) {
|
||||
if (programs.length > 1) {
|
||||
userProfile.payload.uiObject.setErrorMessage('Only one ' + programNodeType + ' is allowed.')
|
||||
return
|
||||
}
|
||||
if (programs.length === 1) {
|
||||
return programs[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1044,6 +1044,11 @@
|
||||
"name": "Bonus Program",
|
||||
"propertyName": "bonusProgram",
|
||||
"functionName": "newFoundationsUtilitiesBonusProgram"
|
||||
},
|
||||
{
|
||||
"name": "Validations",
|
||||
"propertyName": "validations",
|
||||
"functionName": "newFoundationsUtilitiesValidations"
|
||||
}
|
||||
],
|
||||
"spaces": [
|
||||
|
||||
Reference in new issue
Block a user