diff --git a/Projects/Governance/UI/Function-Libraries/MentorshipProgram.js b/Projects/Governance/UI/Function-Libraries/MentorshipProgram.js index 90441a830..6e7ed04c3 100644 --- a/Projects/Governance/UI/Function-Libraries/MentorshipProgram.js +++ b/Projects/Governance/UI/Function-Libraries/MentorshipProgram.js @@ -39,7 +39,7 @@ function newGovernanceFunctionLibraryMentorshipProgram() { if (userProfile.tokenSwitch.mentorshipProgram === undefined) { continue } if (userProfile.tokenSwitch.mentorshipProgram.payload === undefined) { continue } - resetUserMentorships(userProfile.tokenSwitch.mentorshipProgram) + reserMentorshipProgram(userProfile.tokenSwitch.mentorshipProgram) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] @@ -60,10 +60,10 @@ function newGovernanceFunctionLibraryMentorshipProgram() { calculateMentorshipProgram(userProfile.tokenSwitch.mentorshipProgram) } - function resetUserMentorships(node) { + function reserMentorshipProgram(node) { if (node === undefined) { return } if (node.payload === undefined) { return } - node.payload.mentorships = { + node.payload.mentorshipProgram = { count: 0, outgoingPower: 0, ownPower: 0, @@ -81,7 +81,7 @@ function newGovernanceFunctionLibraryMentorshipProgram() { node.tokenSwitch !== undefined && node.tokenSwitch.mentorshipProgram !== undefined ) { - resetUserMentorships(node.tokenSwitch.mentorshipProgram) + reserMentorshipProgram(node.tokenSwitch.mentorshipProgram) return } /* @@ -91,7 +91,7 @@ function newGovernanceFunctionLibraryMentorshipProgram() { node.type === 'Mentorship Program' && node.userReferrer !== undefined ) { - resetUserMentorships(node.userReferrer) + reserMentorshipProgram(node.userReferrer) return } /* @@ -102,7 +102,7 @@ function newGovernanceFunctionLibraryMentorshipProgram() { node.type === 'User Referrer' && node.payload.referenceParent !== undefined ) { - resetUserMentorships(node.payload.referenceParent) + reserMentorshipProgram(node.payload.referenceParent) return } } @@ -121,7 +121,7 @@ function newGovernanceFunctionLibraryMentorshipProgram() { /* The Own Power is the power generated by the same User Profile tokens, not inherited from others. */ - mentorshipProgram.payload.mentorships.ownPower = referringPower + mentorshipProgram.payload.mentorshipProgram.ownPower = referringPower distributeMentorshipPower(mentorshipProgram, referringPower, count) } @@ -142,18 +142,18 @@ function newGovernanceFunctionLibraryMentorshipProgram() { at the count parameters. If we are processing the User Profile of this Mentorship Program then we will add zero, otherwise, 1. */ - node.payload.mentorships.count = node.payload.mentorships.count + count + node.payload.mentorshipProgram.count = node.payload.mentorshipProgram.count + count /* The outgoingPower of this node will be accumulating all the referringPower flowing through it, no matter from where it comes. */ - node.payload.mentorships.outgoingPower = node.payload.mentorships.outgoingPower + referringPower + node.payload.mentorshipProgram.outgoingPower = node.payload.mentorshipProgram.outgoingPower + referringPower /* We need to adjust the balance that holds the accumulationt of all incomingPower of all Mentorship Program nodes. To do this we will substratct the current incomingPower, bacause it is going to be recalculated inmediatelly after this, and then we will add it again after the recalcualtion. */ - accumulatedIncomingMentorshipPower = accumulatedIncomingMentorshipPower - node.payload.mentorships.incomingPower + accumulatedIncomingMentorshipPower = accumulatedIncomingMentorshipPower - node.payload.mentorshipProgram.incomingPower /* At any point in time, the incomingPower will be equal to the total of the outgoingPower minus the ownPower. This is like this because the outgoingPower is the accumulation of all the @@ -161,12 +161,12 @@ function newGovernanceFunctionLibraryMentorshipProgram() { substract the ownPower, we will have the accumulation of all the incomingPower, which means all the power coming from other User Profiles referencing this one. */ - node.payload.mentorships.incomingPower = node.payload.mentorships.outgoingPower - node.payload.mentorships.ownPower + node.payload.mentorshipProgram.incomingPower = node.payload.mentorshipProgram.outgoingPower - node.payload.mentorshipProgram.ownPower /* Now that we have the incomingPower calculated again, we can add it again to the balance of all the incomingPower of all Mentorship Program nodes. */ - accumulatedIncomingMentorshipPower = accumulatedIncomingMentorshipPower + node.payload.mentorships.incomingPower + accumulatedIncomingMentorshipPower = accumulatedIncomingMentorshipPower + node.payload.mentorshipProgram.incomingPower if (node.userReferrer !== undefined) { distributeMentorshipPower(node.userReferrer, referringPower, 0) @@ -216,19 +216,19 @@ function newGovernanceFunctionLibraryMentorshipProgram() { mentorshipProgram.payload.uiObject.setErrorMessage("Tokens Awarded Node is needed in order for this Program to get Tokens from the Mentorship Program Pool.") return } - mentorshipProgram.payload.mentorships.awarded.tokens = mentorshipProgram.payload.mentorships.incomingPower * totalPowerRewardRatio + mentorshipProgram.payload.mentorshipProgram.awarded.tokens = mentorshipProgram.payload.mentorshipProgram.incomingPower * totalPowerRewardRatio /* As per the system rules, the Mentorship Program will not give tokens to users that do not ha their own Referrer set up, unless it has a big amount of tokens (this last condition is for the edge case where a user it at the top of the mentorship pyramid.) */ if ( - mentorshipProgram.payload.mentorships.ownPower < 1000000 && + mentorshipProgram.payload.mentorshipProgram.ownPower < 1000000 && (mentorshipProgram.userReferrer === undefined || mentorshipProgram.userReferrer.payload.referenceParent === undefined) ) { - mentorshipProgram.payload.uiObject.setErrorMessage("In order to be awarded " + mentorshipProgram.payload.mentorships.awarded.tokens + " SA Tokens from your mentorships, you need first to define yourself who your referrer is.") - mentorshipProgram.payload.mentorships.awarded.tokens = 0 + mentorshipProgram.payload.uiObject.setErrorMessage("In order to be awarded " + mentorshipProgram.payload.mentorshipProgram.awarded.tokens + " SA Tokens from your mentorships, you need first to define yourself who your referrer is.") + mentorshipProgram.payload.mentorshipProgram.awarded.tokens = 0 } drawMentorshipProgram(mentorshipProgram) @@ -236,9 +236,9 @@ function newGovernanceFunctionLibraryMentorshipProgram() { function drawUserReferrer(node) { if (node.payload !== undefined) { - const ownPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.mentorships.ownPower) - const incomingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.mentorships.incomingPower) - const outgoingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.mentorships.outgoingPower) + const ownPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.mentorshipProgram.ownPower) + const incomingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.mentorshipProgram.incomingPower) + const outgoingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.mentorshipProgram.outgoingPower) node.payload.uiObject.valueAngleOffset = 180 node.payload.uiObject.valueAtAngle = true @@ -262,12 +262,15 @@ function newGovernanceFunctionLibraryMentorshipProgram() { } if (node.tokensAwarded !== undefined && node.tokensAwarded.payload !== undefined) { - const tokensAwardedText = new Intl.NumberFormat().format(node.payload.mentorships.awarded.tokens) + const tokensAwardedText = new Intl.NumberFormat().format(node.payload.mentorshipProgram.awarded.tokens) node.tokensAwarded.payload.uiObject.statusAngleOffset = 0 node.tokensAwarded.payload.uiObject.statusAtAngle = false + node.tokensAwarded.payload.uiObject.valueAngleOffset = 0 + node.tokensAwarded.payload.uiObject.valueAtAngle = false node.tokensAwarded.payload.uiObject.setValue(tokensAwardedText + ' SA Tokens') + node.tokensAwarded.payload.uiObject.setStatus('From '+ node.payload.referralProgram.count + ' Mentorships.') } } } diff --git a/Projects/Governance/UI/Function-Libraries/ReferralProgram.js b/Projects/Governance/UI/Function-Libraries/ReferralProgram.js index 703af10fa..12da96fe5 100644 --- a/Projects/Governance/UI/Function-Libraries/ReferralProgram.js +++ b/Projects/Governance/UI/Function-Libraries/ReferralProgram.js @@ -39,7 +39,7 @@ function newGovernanceFunctionLibraryReferralProgram() { if (userProfile.tokenSwitch.referralProgram === undefined) { continue } if (userProfile.tokenSwitch.referralProgram.payload === undefined) { continue } - resetUserReferrals(userProfile.tokenSwitch.referralProgram) + reserReferralProgram(userProfile.tokenSwitch.referralProgram) } for (let i = 0; i < userProfiles.length; i++) { let userProfile = userProfiles[i] @@ -60,10 +60,10 @@ function newGovernanceFunctionLibraryReferralProgram() { calculateReferralProgram(userProfile.tokenSwitch.referralProgram) } - function resetUserReferrals(node) { + function reserReferralProgram(node) { if (node === undefined) { return } if (node.payload === undefined) { return } - node.payload.referrals = { + node.payload.referralProgram = { count: 0, outgoingPower: 0, ownPower: 0, @@ -81,7 +81,7 @@ function newGovernanceFunctionLibraryReferralProgram() { node.tokenSwitch !== undefined && node.tokenSwitch.referralProgram !== undefined ) { - resetUserReferrals(node.tokenSwitch.referralProgram) + reserReferralProgram(node.tokenSwitch.referralProgram) return } /* @@ -91,7 +91,7 @@ function newGovernanceFunctionLibraryReferralProgram() { node.type === 'Referral Program' && node.userReferrer !== undefined ) { - resetUserReferrals(node.userReferrer) + reserReferralProgram(node.userReferrer) return } /* @@ -102,7 +102,7 @@ function newGovernanceFunctionLibraryReferralProgram() { node.type === 'User Referrer' && node.payload.referenceParent !== undefined ) { - resetUserReferrals(node.payload.referenceParent) + reserReferralProgram(node.payload.referenceParent) return } } @@ -121,7 +121,7 @@ function newGovernanceFunctionLibraryReferralProgram() { /* The Own Power is the power generated by the same User Profile tokens, not inherited from others. */ - referralProgram.payload.referrals.ownPower = referringPower + referralProgram.payload.referralProgram.ownPower = referringPower distributeReferralPower(referralProgram, referringPower, count) } @@ -142,18 +142,18 @@ function newGovernanceFunctionLibraryReferralProgram() { at the count parameters. If we are processing the User Profile of this Referral Program then we will add zero, otherwise, 1. */ - node.payload.referrals.count = node.payload.referrals.count + count + node.payload.referralProgram.count = node.payload.referralProgram.count + count /* The outgoingPower of this node will be accumulating all the referringPower flowing through it, no matter from where it comes. */ - node.payload.referrals.outgoingPower = node.payload.referrals.outgoingPower + referringPower + node.payload.referralProgram.outgoingPower = node.payload.referralProgram.outgoingPower + referringPower /* We need to adjust the balance that holds the accumulationt of all incomingPower of all Referral Program nodes. To do this we will substratct the current incomingPower, bacause it is going to be recalculated inmediatelly after this, and then we will add it again after the recalcualtion. */ - accumulatedIncomingReferralPower = accumulatedIncomingReferralPower - node.payload.referrals.incomingPower + accumulatedIncomingReferralPower = accumulatedIncomingReferralPower - node.payload.referralProgram.incomingPower /* At any point in time, the incomingPower will be equal to the total of the outgoingPower minus the ownPower. This is like this because the outgoingPower is the accumulation of all the @@ -161,12 +161,12 @@ function newGovernanceFunctionLibraryReferralProgram() { substract the ownPower, we will have the accumulation of all the incomingPower, which means all the power coming from other User Profiles referencing this one. */ - node.payload.referrals.incomingPower = node.payload.referrals.outgoingPower - node.payload.referrals.ownPower + node.payload.referralProgram.incomingPower = node.payload.referralProgram.outgoingPower - node.payload.referralProgram.ownPower /* Now that we have the incomingPower calculated again, we can add it again to the balance of all the incomingPower of all Referral Program nodes. */ - accumulatedIncomingReferralPower = accumulatedIncomingReferralPower + node.payload.referrals.incomingPower + accumulatedIncomingReferralPower = accumulatedIncomingReferralPower + node.payload.referralProgram.incomingPower if (node.userReferrer !== undefined) { distributeReferralPower(node.userReferrer, referringPower, 0) @@ -216,19 +216,19 @@ function newGovernanceFunctionLibraryReferralProgram() { referralProgram.payload.uiObject.setErrorMessage("Tokens Awarded Node is needed in order for this Program to get Tokens from the Referral Program Pool.") return } - referralProgram.payload.referrals.awarded.tokens = referralProgram.payload.referrals.incomingPower * totalPowerRewardRatio + referralProgram.payload.referralProgram.awarded.tokens = referralProgram.payload.referralProgram.incomingPower * totalPowerRewardRatio /* As per the system rules, the Referral Program will not give tokens to users that do not ha their own Referrer set up, unless it has a big amount of tokens (this last condition is for the edge case where a user it at the top of the referral pyramid.) */ if ( - referralProgram.payload.referrals.ownPower < 1000000 && + referralProgram.payload.referralProgram.ownPower < 1000000 && (referralProgram.userReferrer === undefined || referralProgram.userReferrer.payload.referenceParent === undefined) ) { - referralProgram.payload.uiObject.setErrorMessage("In order to be awarded " + referralProgram.payload.referrals.awarded.tokens + " SA Tokens from your referrals, you need first to define yourself who your referrer is.") - referralProgram.payload.referrals.awarded.tokens = 0 + referralProgram.payload.uiObject.setErrorMessage("In order to be awarded " + referralProgram.payload.referralProgram.awarded.tokens + " SA Tokens from your referrals, you need first to define yourself who your referrer is.") + referralProgram.payload.referralProgram.awarded.tokens = 0 } drawReferralProgram(referralProgram) @@ -236,9 +236,9 @@ function newGovernanceFunctionLibraryReferralProgram() { function drawUserReferrer(node) { if (node.payload !== undefined) { - const ownPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referrals.ownPower) - const incomingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referrals.incomingPower) - const outgoingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referrals.outgoingPower) + const ownPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referralProgram.ownPower) + const incomingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referralProgram.incomingPower) + const outgoingPowerText = new Intl.NumberFormat().format(node.payload.parentNode.payload.referralProgram.outgoingPower) node.payload.uiObject.valueAngleOffset = 180 node.payload.uiObject.valueAtAngle = true @@ -262,12 +262,15 @@ function newGovernanceFunctionLibraryReferralProgram() { } if (node.tokensAwarded !== undefined && node.tokensAwarded.payload !== undefined) { - const tokensAwardedText = new Intl.NumberFormat().format(node.payload.referrals.awarded.tokens) + const tokensAwardedText = new Intl.NumberFormat().format(node.payload.referralProgram.awarded.tokens) node.tokensAwarded.payload.uiObject.statusAngleOffset = 0 node.tokensAwarded.payload.uiObject.statusAtAngle = false + node.tokensAwarded.payload.uiObject.valueAngleOffset = 0 + node.tokensAwarded.payload.uiObject.valueAtAngle = false node.tokensAwarded.payload.uiObject.setValue(tokensAwardedText + ' SA Tokens') + node.tokensAwarded.payload.uiObject.setStatus('From '+ node.payload.referralProgram.count + ' Referrals.') } } }