From e606fd5101eb6271200d1bd22a0b2194970e1cc1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Mon, 21 Jun 2021 11:58:36 +0200 Subject: [PATCH] Token Power Switch Refactoring --- ...oken-switch.png => token-power-switch.png} | Bin .../Plugins/User-Profiles/Julian-Molina.json | 6 +-- .../User-Profiles/Luis-Fernando-Molina.json | 6 +-- .../Schemas/App-Schema/claims-program.json | 2 +- .../App-Schema/mentorship-program.json | 2 +- .../Schemas/App-Schema/referral-program.json | 2 +- .../Schemas/App-Schema/staking-program.json | 2 +- .../Schemas/App-Schema/support-program.json | 2 +- ...ensSwitch.json => token-power-switch.json} | 4 +- ...TokensAwarded.json => tokens-awarded.json} | 0 .../Schemas/App-Schema/user-profile.json | 10 ++-- .../Schemas/App-Schema/voting-program.json | 2 +- .../UI/Function-Libraries/ReferralProgram.js | 36 ++++++------- .../UI/Function-Libraries/TokenPower.js | 16 +++--- .../Governance/UI/Function-Libraries/Votes.js | 18 +++---- .../UI/Utilities/MandatoryProgram.js | 48 +++++++++--------- 16 files changed, 78 insertions(+), 78 deletions(-) rename Projects/Governance/Icons/{token-switch.png => token-power-switch.png} (100%) rename Projects/Governance/Schemas/App-Schema/{tokensSwitch.json => token-power-switch.json} (97%) rename Projects/Governance/Schemas/App-Schema/{TokensAwarded.json => tokens-awarded.json} (100%) diff --git a/Projects/Governance/Icons/token-switch.png b/Projects/Governance/Icons/token-power-switch.png similarity index 100% rename from Projects/Governance/Icons/token-switch.png rename to Projects/Governance/Icons/token-power-switch.png diff --git a/Projects/Governance/Plugins/User-Profiles/Julian-Molina.json b/Projects/Governance/Plugins/User-Profiles/Julian-Molina.json index ef80bb5b5..6c5b2049a 100644 --- a/Projects/Governance/Plugins/User-Profiles/Julian-Molina.json +++ b/Projects/Governance/Plugins/User-Profiles/Julian-Molina.json @@ -3,9 +3,9 @@ "name": "Julian-Molina", "config": "{\n \"signature\": {\n \"message\": \"julian-molina\",\n \"messageHash\": \"0x34eae63163cc918a1a1fab82836b0f15e33051925812cf7d5f8ffe5ff0854f2c\",\n \"v\": \"0x1b\",\n \"r\": \"0x8560ff34239215408cb869d3c90c30ed11ab6634c4269b255d2b4159b7690fe5\",\n \"s\": \"0x017b2c5e080b0f340dcd09f8ba5c67119a3b62c375252d96f541c57db109a0b7\",\n \"signature\": \"0x8560ff34239215408cb869d3c90c30ed11ab6634c4269b255d2b4159b7690fe5017b2c5e080b0f340dcd09f8ba5c67119a3b62c375252d96f541c57db109a0b71b\"\n }\n}", "project": "Governance", - "tokenSwitch": { - "type": "Token Switch", - "name": "New Token Switch", + "tokenPowerSwitch": { + "type": "Token Power Switch", + "name": "New Token Power Switch", "config": "{}", "project": "Governance", "referralProgram": { diff --git a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json index 8e6d3cea9..50a09d629 100644 --- a/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json +++ b/Projects/Governance/Plugins/User-Profiles/Luis-Fernando-Molina.json @@ -3,9 +3,9 @@ "name": "Luis-Fernando-Molina", "config": "{\n \"tokens\": 10000000,\n \"signature\": {\n \"message\": \"Luis-Fernando-Molina\",\n \"messageHash\": \"0x443abf3389e332a62d21b84dd12e271cb428d334195d3aeb986ca85ee53cccb9\",\n \"v\": \"0x1b\",\n \"r\": \"0x90293b042c180aa21b05f0356f31688c597be4ff2df136f63a2b8a899c658eb0\",\n \"s\": \"0x42abf909024d34217430e42ebadc96b7834218cc86a4c295a2ae419ff2fca6e3\",\n \"signature\": \"0x90293b042c180aa21b05f0356f31688c597be4ff2df136f63a2b8a899c658eb042abf909024d34217430e42ebadc96b7834218cc86a4c295a2ae419ff2fca6e31b\"\n }\n}", "project": "Governance", - "tokenSwitch": { - "type": "Token Switch", - "name": "New Token Switch", + "tokenPowerSwitch": { + "type": "Token Power Switch", + "name": "New Token Power Switch", "config": "{}", "project": "Governance", "referralProgram": { diff --git a/Projects/Governance/Schemas/App-Schema/claims-program.json b/Projects/Governance/Schemas/App-Schema/claims-program.json index 86ec39c65..c91831a44 100644 --- a/Projects/Governance/Schemas/App-Schema/claims-program.json +++ b/Projects/Governance/Schemas/App-Schema/claims-program.json @@ -56,7 +56,7 @@ "config": "{}" }, "attachingRules": { - "compatibleTypes": "->Token Switch->" + "compatibleTypes": "->Token Power Switch->" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/Schemas/App-Schema/mentorship-program.json b/Projects/Governance/Schemas/App-Schema/mentorship-program.json index 9bdf5ed90..24d587b52 100644 --- a/Projects/Governance/Schemas/App-Schema/mentorship-program.json +++ b/Projects/Governance/Schemas/App-Schema/mentorship-program.json @@ -42,7 +42,7 @@ "config": "{}" }, "attachingRules": { - "compatibleTypes": "->Token Switch->" + "compatibleTypes": "->Token Power Switch->" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/Schemas/App-Schema/referral-program.json b/Projects/Governance/Schemas/App-Schema/referral-program.json index b16edcda3..9c7c831f5 100644 --- a/Projects/Governance/Schemas/App-Schema/referral-program.json +++ b/Projects/Governance/Schemas/App-Schema/referral-program.json @@ -44,7 +44,7 @@ "config": "{}" }, "attachingRules": { - "compatibleTypes": "->Token Switch->" + "compatibleTypes": "->Token Power Switch->" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/Schemas/App-Schema/staking-program.json b/Projects/Governance/Schemas/App-Schema/staking-program.json index d8e103712..86dab37b1 100644 --- a/Projects/Governance/Schemas/App-Schema/staking-program.json +++ b/Projects/Governance/Schemas/App-Schema/staking-program.json @@ -35,7 +35,7 @@ "config": "{}" }, "attachingRules": { - "compatibleTypes": "->Token Switch->" + "compatibleTypes": "->Token Power Switch->" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/Schemas/App-Schema/support-program.json b/Projects/Governance/Schemas/App-Schema/support-program.json index a0bfb71e3..9e36f802d 100644 --- a/Projects/Governance/Schemas/App-Schema/support-program.json +++ b/Projects/Governance/Schemas/App-Schema/support-program.json @@ -42,7 +42,7 @@ "config": "{}" }, "attachingRules": { - "compatibleTypes": "->Token Switch->" + "compatibleTypes": "->Token Power Switch->" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/Schemas/App-Schema/tokensSwitch.json b/Projects/Governance/Schemas/App-Schema/token-power-switch.json similarity index 97% rename from Projects/Governance/Schemas/App-Schema/tokensSwitch.json rename to Projects/Governance/Schemas/App-Schema/token-power-switch.json index caad9fc1d..76ccc55a6 100644 --- a/Projects/Governance/Schemas/App-Schema/tokensSwitch.json +++ b/Projects/Governance/Schemas/App-Schema/token-power-switch.json @@ -1,5 +1,5 @@ { - "type": "Token Switch", + "type": "Token Power Switch", "menuItems": [ { "action": "Configure", @@ -84,7 +84,7 @@ "attachingRules": { "compatibleTypes": "->User Profile->" }, - "propertyNameAtParent": "tokenSwitch", + "propertyNameAtParent": "tokenPowerSwitch", "childrenNodesProperties": [ { "name": "referralProgram", diff --git a/Projects/Governance/Schemas/App-Schema/TokensAwarded.json b/Projects/Governance/Schemas/App-Schema/tokens-awarded.json similarity index 100% rename from Projects/Governance/Schemas/App-Schema/TokensAwarded.json rename to Projects/Governance/Schemas/App-Schema/tokens-awarded.json diff --git a/Projects/Governance/Schemas/App-Schema/user-profile.json b/Projects/Governance/Schemas/App-Schema/user-profile.json index 938527f3b..e77884227 100644 --- a/Projects/Governance/Schemas/App-Schema/user-profile.json +++ b/Projects/Governance/Schemas/App-Schema/user-profile.json @@ -12,10 +12,10 @@ "action": "Add UI Object", "actionProject": "Foundations", "disableIfPropertyIsDefined": true, - "propertyToCheckFor": "tokenSwitch", + "propertyToCheckFor": "tokenPowerSwitch", "actionFunction": "payload.executeAction", - "label": "Add Token Switch", - "relatedUiObject": "Token Switch" + "label": "Add Token Power Switch", + "relatedUiObject": "Token Power Switch" }, { "action": "Delete UI Object", @@ -40,9 +40,9 @@ "level": 0, "childrenNodesProperties": [ { - "name": "tokenSwitch", + "name": "tokenPowerSwitch", "type": "node", - "childType": "Token Switch", + "childType": "Token Power Switch", "autoAdd": true } ] diff --git a/Projects/Governance/Schemas/App-Schema/voting-program.json b/Projects/Governance/Schemas/App-Schema/voting-program.json index 04185a618..83a9aec37 100644 --- a/Projects/Governance/Schemas/App-Schema/voting-program.json +++ b/Projects/Governance/Schemas/App-Schema/voting-program.json @@ -42,7 +42,7 @@ "config": "{}" }, "attachingRules": { - "compatibleTypes": "->Token Switch->" + "compatibleTypes": "->Token Power Switch->" }, "addLeftIcons": true, "level": 1, diff --git a/Projects/Governance/UI/Function-Libraries/ReferralProgram.js b/Projects/Governance/UI/Function-Libraries/ReferralProgram.js index d6d4950a4..4864d4028 100644 --- a/Projects/Governance/UI/Function-Libraries/ReferralProgram.js +++ b/Projects/Governance/UI/Function-Libraries/ReferralProgram.js @@ -35,29 +35,29 @@ function newGovernanceFunctionLibraryReferralProgram() { for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch.referralProgram === undefined) { continue } - if (userProfile.tokenSwitch.referralProgram.payload === undefined) { continue } + if (userProfile.tokenPowerSwitch === undefined) { continue } + if (userProfile.tokenPowerSwitch.referralProgram === undefined) { continue } + if (userProfile.tokenPowerSwitch.referralProgram.payload === undefined) { continue } - reserReferralProgram(userProfile.tokenSwitch.referralProgram) + reserReferralProgram(userProfile.tokenPowerSwitch.referralProgram) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch.referralProgram === undefined) { continue } - if (userProfile.tokenSwitch.referralProgram.payload === undefined) { continue } + if (userProfile.tokenPowerSwitch === undefined) { continue } + if (userProfile.tokenPowerSwitch.referralProgram === undefined) { continue } + if (userProfile.tokenPowerSwitch.referralProgram.payload === undefined) { continue } - distributeReferralProgram(userProfile.tokenSwitch.referralProgram) + distributeReferralProgram(userProfile.tokenPowerSwitch.referralProgram) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch.referralProgram === undefined) { continue } - if (userProfile.tokenSwitch.referralProgram.payload === undefined) { continue } + if (userProfile.tokenPowerSwitch === undefined) { continue } + if (userProfile.tokenPowerSwitch.referralProgram === undefined) { continue } + if (userProfile.tokenPowerSwitch.referralProgram.payload === undefined) { continue } - calculateReferralProgram(userProfile.tokenSwitch.referralProgram) + calculateReferralProgram(userProfile.tokenPowerSwitch.referralProgram) } function reserReferralProgram(node) { @@ -75,13 +75,13 @@ function newGovernanceFunctionLibraryReferralProgram() { } if ( node.type === 'User Profile' && - node.tokenSwitch !== undefined + node.tokenPowerSwitch !== undefined ) { - reserReferralProgram(node.tokenSwitch) + reserReferralProgram(node.tokenPowerSwitch) return } if ( - node.type === 'Token Switch' && + node.type === 'Token Power Switch' && node.referralProgram !== undefined ) { reserReferralProgram(node.referralProgram) @@ -177,12 +177,12 @@ function newGovernanceFunctionLibraryReferralProgram() { break } case 'User Profile': { - if (node.tokenSwitch !== undefined) { - distributeReferralPower(node.tokenSwitch, referringPower, 0) + if (node.tokenPowerSwitch !== undefined) { + distributeReferralPower(node.tokenPowerSwitch, referringPower, 0) } break } - case 'Token Switch': { + case 'Token Power Switch': { if (node.referralProgram !== undefined) { distributeReferralPower(node.referralProgram, referringPower, 1) } diff --git a/Projects/Governance/UI/Function-Libraries/TokenPower.js b/Projects/Governance/UI/Function-Libraries/TokenPower.js index fc8e533eb..708d2259b 100644 --- a/Projects/Governance/UI/Function-Libraries/TokenPower.js +++ b/Projects/Governance/UI/Function-Libraries/TokenPower.js @@ -78,20 +78,20 @@ function newGovernanceFunctionLibraryTokenPower() { /* Before we start we will do some validations: */ - if (userProfile.tokenSwitch === undefined) { - userProfile.payload.uiObject.setErrorMessage("You need to have a Token Switch child node.") + if (userProfile.tokenPowerSwitch === undefined) { + userProfile.payload.uiObject.setErrorMessage("You need to have a Token Power Switch child node.") return } - if (userProfile.tokenSwitch.referralProgram === undefined) { - userProfile.tokenSwitch.payload.uiObject.setErrorMessage("You need to have a Referral Program child node.") + if (userProfile.tokenPowerSwitch.referralProgram === undefined) { + userProfile.tokenPowerSwitch.payload.uiObject.setErrorMessage("You need to have a Referral Program child node.") return } - if (userProfile.tokenSwitch.mentorshipProgram === undefined) { - userProfile.tokenSwitch.payload.uiObject.setErrorMessage("You need to have a Mentorship Program child node.") + if (userProfile.tokenPowerSwitch.mentorshipProgram === undefined) { + userProfile.tokenPowerSwitch.payload.uiObject.setErrorMessage("You need to have a Mentorship Program child node.") return } - if (userProfile.tokenSwitch.supportProgram === undefined) { - userProfile.tokenSwitch.payload.uiObject.setErrorMessage("You need to have a Spupport Program child node.") + if (userProfile.tokenPowerSwitch.supportProgram === undefined) { + userProfile.tokenPowerSwitch.payload.uiObject.setErrorMessage("You need to have a Spupport Program child node.") return } diff --git a/Projects/Governance/UI/Function-Libraries/Votes.js b/Projects/Governance/UI/Function-Libraries/Votes.js index 7c4f6392d..be6166f71 100644 --- a/Projects/Governance/UI/Function-Libraries/Votes.js +++ b/Projects/Governance/UI/Function-Libraries/Votes.js @@ -42,22 +42,22 @@ function newGovernanceFunctionLibraryVotes() { for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch.votingProgram === undefined) { continue } - if (userProfile.tokenSwitch.votingProgram.payload === undefined) { continue } + if (userProfile.tokenPowerSwitch === undefined) { continue } + if (userProfile.tokenPowerSwitch.votingProgram === undefined) { continue } + if (userProfile.tokenPowerSwitch.votingProgram.payload === undefined) { continue } - resetVotes(userProfile.tokenSwitch.votingProgram) + resetVotes(userProfile.tokenPowerSwitch.votingProgram) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch.votingProgram === undefined) { continue } - if (userProfile.tokenSwitch.votingProgram.payload === undefined) { continue } + if (userProfile.tokenPowerSwitch === undefined) { continue } + if (userProfile.tokenPowerSwitch.votingProgram === undefined) { continue } + if (userProfile.tokenPowerSwitch.votingProgram.payload === undefined) { continue } - userProfile.tokenSwitch.votingProgram.payload.votes = userProfile.tokenSwitch.votingProgram.payload.tokenPower + userProfile.tokenPowerSwitch.votingProgram.payload.votes = userProfile.tokenPowerSwitch.votingProgram.payload.tokenPower - distributeVotingProgram(userProfile.tokenSwitch.votingProgram) + distributeVotingProgram(userProfile.tokenPowerSwitch.votingProgram) } function resetVotes(node) { diff --git a/Projects/Governance/UI/Utilities/MandatoryProgram.js b/Projects/Governance/UI/Utilities/MandatoryProgram.js index 5eb18b9f9..6c4fbbafe 100644 --- a/Projects/Governance/UI/Utilities/MandatoryProgram.js +++ b/Projects/Governance/UI/Utilities/MandatoryProgram.js @@ -41,40 +41,40 @@ function newFoundationsUtilitiesMandatoryProgram() { for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName] === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName].payload === undefined) { continue } + if (userProfile.tokenPowerSwitch === undefined) { continue } + if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue } + if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue } - reserProgram(userProfile.tokenSwitch[programPropertyName]) + reserProgram(userProfile.tokenPowerSwitch[programPropertyName]) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName] === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName].payload === undefined) { continue } + if (userProfile.tokenPowerSwitch === undefined) { continue } + if (userProfile.tokenPowerSwitch[programPropertyName] === undefined) { continue } + if (userProfile.tokenPowerSwitch[programPropertyName].payload === undefined) { continue } - validateProgram(userProfile.tokenSwitch[programPropertyName]) + validateProgram(userProfile.tokenPowerSwitch[programPropertyName]) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName] === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName].payload === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName].payload[programPropertyName].isActive === false) { continue } + 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 } - distributeProgram(userProfile.tokenSwitch[programPropertyName]) + distributeProgram(userProfile.tokenPowerSwitch[programPropertyName]) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] - if (userProfile.tokenSwitch === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName] === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName].payload === undefined) { continue } - if (userProfile.tokenSwitch[programPropertyName].payload[programPropertyName].isActive === false) { continue } + 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 } - calculateProgram(userProfile.tokenSwitch[programPropertyName]) + calculateProgram(userProfile.tokenPowerSwitch[programPropertyName]) } function reserProgram(node) { @@ -92,13 +92,13 @@ function newFoundationsUtilitiesMandatoryProgram() { } if ( node.type === 'User Profile' && - node.tokenSwitch !== undefined + node.tokenPowerSwitch !== undefined ) { - reserProgram(node.tokenSwitch) + reserProgram(node.tokenPowerSwitch) return } if ( - node.type === 'Token Switch' && + node.type === 'Token Power Switch' && node[programPropertyName] !== undefined ) { reserProgram(node[programPropertyName]) @@ -238,12 +238,12 @@ function newFoundationsUtilitiesMandatoryProgram() { break } case 'User Profile': { - if (node.tokenSwitch !== undefined) { - distributeProgramPower(node.tokenSwitch, mentoshipPower, 0) + if (node.tokenPowerSwitch !== undefined) { + distributeProgramPower(node.tokenPowerSwitch, mentoshipPower, 0) } break } - case 'Token Switch': { + case 'Token Power Switch': { if (node[programPropertyName] !== undefined) { distributeProgramPower(node[programPropertyName], mentoshipPower, 1) }