diff --git a/Projects/Governance/Schemas/App-Schema/profile-constructor.json b/Projects/Governance/Schemas/App-Schema/profile-constructor.json index 6d10239f10..a86eda326a 100644 --- a/Projects/Governance/Schemas/App-Schema/profile-constructor.json +++ b/Projects/Governance/Schemas/App-Schema/profile-constructor.json @@ -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", @@ -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", diff --git a/Projects/Governance/UI/Function-Libraries/ActionSwitch.js b/Projects/Governance/UI/Function-Libraries/ActionSwitch.js index 576121a066..2e374de5c5 100644 --- a/Projects/Governance/UI/Function-Libraries/ActionSwitch.js +++ b/Projects/Governance/UI/Function-Libraries/ActionSwitch.js @@ -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': diff --git a/Projects/Governance/UI/Function-Libraries/ProfileConstructor.js b/Projects/Governance/UI/Function-Libraries/ProfileConstructor.js index b9497857f8..6b34a0844e 100644 --- a/Projects/Governance/UI/Function-Libraries/ProfileConstructor.js +++ b/Projects/Governance/UI/Function-Libraries/ProfileConstructor.js @@ -1,6 +1,7 @@ function newGovernanceFunctionLibraryProfileConstructor() { let thisObject = { - buildProfile: buildProfile, + buildProfileWallet: buildProfile, + buildProfileMnemonic: buildProfile, installSigningAccounts: installSigningAccounts, buildProfileWalletConnect: buildProfileWalletConnect } @@ -9,7 +10,8 @@ function newGovernanceFunctionLibraryProfileConstructor() { function buildProfile( node, - rootNodes + rootNodes, + type ) { /* Some validations first... @@ -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() { @@ -85,7 +95,7 @@ function newGovernanceFunctionLibraryProfileConstructor() { signUserProfileData(response.address, response.privateKey) } } - + function signUserProfileData(address, privateKey) { let request = { @@ -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) { @@ -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( @@ -125,7 +135,7 @@ 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 @@ -133,15 +143,15 @@ function newGovernanceFunctionLibraryProfileConstructor() { 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') @@ -180,6 +190,7 @@ function newGovernanceFunctionLibraryProfileConstructor() { } } + function installSigningAccounts( node, rootNodes