Token Power Switch Refactoring
This commit is contained in:
1 parent
dae98d3fd4
commit
e606fd5101
16 files changed
+78
-78
No files matched your search
File renamed without changes.
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -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": {
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
"config": "{}"
|
||||
},
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Token Switch->"
|
||||
"compatibleTypes": "->Token Power Switch->"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 1,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"config": "{}"
|
||||
},
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Token Switch->"
|
||||
"compatibleTypes": "->Token Power Switch->"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 1,
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
"config": "{}"
|
||||
},
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Token Switch->"
|
||||
"compatibleTypes": "->Token Power Switch->"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 1,
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
"config": "{}"
|
||||
},
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Token Switch->"
|
||||
"compatibleTypes": "->Token Power Switch->"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 1,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"config": "{}"
|
||||
},
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Token Switch->"
|
||||
"compatibleTypes": "->Token Power Switch->"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 1,
|
||||
|
||||
+2
-2
@@ -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",
|
||||
File renamed without changes.
@@ -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
|
||||
}
|
||||
]
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
"config": "{}"
|
||||
},
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->Token Switch->"
|
||||
"compatibleTypes": "->Token Power Switch->"
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 1,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user