From 45bbc0b368f6fc983a4404b219de4c14d6542aee Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 25 Jun 2021 00:32:04 +0200 Subject: [PATCH] Stacking Program Fixed --- .../UI/Function-Libraries/StackingProgram.js | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/Projects/Governance/UI/Function-Libraries/StackingProgram.js b/Projects/Governance/UI/Function-Libraries/StackingProgram.js index 1248bf954..e1b82d755 100644 --- a/Projects/Governance/UI/Function-Libraries/StackingProgram.js +++ b/Projects/Governance/UI/Function-Libraries/StackingProgram.js @@ -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