diff --git a/Projects/Foundations/UI/Utilities/Branches.js b/Projects/Foundations/UI/Utilities/Branches.js index 0dc69aa1e..5e2edd95a 100644 --- a/Projects/Foundations/UI/Utilities/Branches.js +++ b/Projects/Foundations/UI/Utilities/Branches.js @@ -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]) } diff --git a/Projects/Governance/UI/Function-Libraries/VotingProgram.js b/Projects/Governance/UI/Function-Libraries/VotingProgram.js index 359d8949a..39ce8b477 100644 --- a/Projects/Governance/UI/Function-Libraries/VotingProgram.js +++ b/Projects/Governance/UI/Function-Libraries/VotingProgram.js @@ -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) {