Token Power Switch Made Recursive Descendants Fixed

This commit is contained in:
Luis Fernando Molina committed 2021-06-25 00:08:53 +02:00
1 parent 25e42e316d
commit d64cf914e2
6 files changed
+2946 -2796

No files matched your search

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
}
]
}
@@ -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)
}
@@ -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]
}
}
}
}
+5
View File
@@ -1044,6 +1044,11 @@
"name": "Bonus Program",
"propertyName": "bonusProgram",
"functionName": "newFoundationsUtilitiesBonusProgram"
},
{
"name": "Validations",
"propertyName": "validations",
"functionName": "newFoundationsUtilitiesValidations"
}
],
"spaces": [