Skip to content

Commit

Permalink
Merge pull request #3104 from NAmorim/develop
Browse files Browse the repository at this point in the history
Clarify user profile creation options
  • Loading branch information
Luis-Fernando-Molina authored Dec 13, 2021
2 parents 4480505 + 0791233 commit 21b47e3
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 16 deletions.
17 changes: 14 additions & 3 deletions Projects/Governance/Schemas/App-Schema/profile-constructor.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,20 @@
"iconPathOff": "configuration"
},
{
"action": "Build Profile",
"action": "Build Profile Wallet",
"actionProject": "Governance",
"label": "Build Profile",
"label": "Build Profile and New Wallet",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
"relatedUiObject": "Profile Constructor",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Build Profile Mnemonic",
"actionProject": "Governance",
"label": "Build Profile with Mnemonic",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
Expand All @@ -22,7 +33,7 @@
{
"action": "Build Profile WalletConnect",
"actionProject": "Governance",
"label": "Build Profile WalletConnect",
"label": "Build Profile with WalletConnect",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
Expand Down
9 changes: 7 additions & 2 deletions Projects/Governance/UI/Function-Libraries/ActionSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ function newGovernanceActionSwitch() {
UI.projects.governance.functionLibraries.claimsProgram.installMissingClaims(action.node, action.rootNodes)
break
}
case 'Build Profile':
case 'Build Profile Wallet':
{
UI.projects.governance.functionLibraries.profileConstructor.buildProfile(action.node, action.rootNodes)
UI.projects.governance.functionLibraries.profileConstructor.buildProfileWallet(action.node, action.rootNodes)
break
}
case 'Build Profile Mnemonic':
{
UI.projects.governance.functionLibraries.profileConstructor.buildProfileMnemonic(action.node, action.rootNodes, 'mnemonic')
break
}
case 'Build Profile WalletConnect':
Expand Down
33 changes: 22 additions & 11 deletions Projects/Governance/UI/Function-Libraries/ProfileConstructor.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
function newGovernanceFunctionLibraryProfileConstructor() {
let thisObject = {
buildProfile: buildProfile,
buildProfileWallet: buildProfile,
buildProfileMnemonic: buildProfile,
installSigningAccounts: installSigningAccounts,
buildProfileWalletConnect: buildProfileWalletConnect
}
Expand All @@ -9,7 +10,8 @@ function newGovernanceFunctionLibraryProfileConstructor() {

function buildProfile(
node,
rootNodes
rootNodes,
type
) {
/*
Some validations first...
Expand All @@ -25,6 +27,14 @@ function newGovernanceFunctionLibraryProfileConstructor() {
return
}

if (type === 'mnemonic' && (mnemonic === undefined || mnemonic === "")) {
node.payload.uiObject.setErrorMessage(
"mnemonic config property missing.",
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
)
return
}

createWallet()

function createWallet() {
Expand Down Expand Up @@ -85,7 +95,7 @@ function newGovernanceFunctionLibraryProfileConstructor() {
signUserProfileData(response.address, response.privateKey)
}
}

function signUserProfileData(address, privateKey) {

let request = {
Expand All @@ -96,9 +106,9 @@ function newGovernanceFunctionLibraryProfileConstructor() {
data: githubUsername
}
}

httpRequest(JSON.stringify(request.params), request.url, onResponse)

function onResponse(err, data) {
/* Lets check the result of the call through the http interface */
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
Expand All @@ -108,9 +118,9 @@ function newGovernanceFunctionLibraryProfileConstructor() {
)
return
}

let response = JSON.parse(data)

/* Lets check the result of the method call */
if (response.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
node.payload.uiObject.setErrorMessage(
Expand All @@ -125,23 +135,23 @@ function newGovernanceFunctionLibraryProfileConstructor() {
'User Profile',
UI.projects.foundations.spaces.designSpace.workspace.workspaceNode.rootNodes
)

UI.projects.visualScripting.functionLibraries.attachDetach.referenceAttachNode(node, userProfile)
/*
Set up a basic profile to start receiving benefits
*/
let finServices = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(userProfile.tokenPowerSwitch, "Financial Programs", userProfile)
finServices.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
finServices.payload.uiObject.menu.internalClick("Add Financial Program")

let stakeProg = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(finServices, "Staking Program", userProfile)
stakeProg.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
stakeProg.payload.uiObject.menu.internalClick("Add Tokens Awarded")

let liquidProgs = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(userProfile.tokenPowerSwitch, "Liquidity Programs", userProfile)
liquidProgs.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
liquidProgs.payload.uiObject.menu.internalClick('Add Liquidity Program')

let liquidProg = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(liquidProgs, "Liquidity Program", userProfile)
liquidProg.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180
liquidProg.payload.uiObject.menu.internalClick('Add Tokens Awarded')
Expand Down Expand Up @@ -180,6 +190,7 @@ function newGovernanceFunctionLibraryProfileConstructor() {
}
}


function installSigningAccounts(
node,
rootNodes
Expand Down

0 comments on commit 21b47e3

Please sign in to comment.