Governance: Simplification of the Process to create a Profile

This commit is contained in:
Luis Fernando Molina committed 2021-08-08 14:50:33 +02:00
1 parent 37d70849ec
commit 513738a22d
3 files changed
+51 -19

No files matched your search

+24 -1
View File
@@ -224,7 +224,7 @@ exports.newGithubServer = function newGithubServer() {
page++
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
let listResponse = await octokit.rest.pulls.list({
owner: owner,
repo: repo,
@@ -400,6 +400,29 @@ exports.newGithubServer = function newGithubServer() {
continue
}
/*
Validation #5: The name of the User Profile node is not the Github Username.
*/
if (userProfile.name !== githubUsername) {
console.log('[INFO] Github Server -> mergeGithubPullRequests -> Validation #5 Failed -> Pull Request "' + pullRequest.title + '" not merged because the Github Username is not equal to the User Profile node\'s name. -> Github Username = ' + githubUsername + '-> userProfile.name = ' + userProfile.name)
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
await octokit.rest.issues.createComment({
owner: owner,
repo: repo,
issue_number: pullRequest.number,
body: 'This Pull Request could not be automatically merged and was closed by the Superalgos Governance System because it was detected that the Github User "' + githubUsername + '" who submitted it, is not equal to the User Profile node\'s name.\n\n User Profile Name = "' + userProfile.name + '"'
});
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
await octokit.rest.pulls.update({
owner: owner,
repo: repo,
pull_number: pullRequest.number,
state: 'closed'
});
continue
}
/*
All validations passed, we will proceed an merge this Pull Request.
*/
await CL.projects.foundations.utilities.asyncFunctions.sleep(GITHUB_API_WAITING_TIME)
@@ -29,13 +29,6 @@
"relatedUiObject": "Positions",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
"label": "Add User Profile",
"relatedUiObject": "User Profile",
"actionFunction": "payload.executeAction"
},
{
"action": "Add UI Object",
"actionProject": "Foundations",
@@ -12,17 +12,19 @@ function newGovernanceFunctionLibraryProfileConstructor() {
/*
Some validations first...
*/
if (node.payload.referenceParent === undefined) {
node.payload.uiObject.setErrorMessage("You need to reference the node that contains the data to be signed.")
return
}
let data = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'githubUsername')
let githubUsername = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'githubUsername')
if (data === undefined || data === "") {
node.payload.referenceParent.payload.uiObject.setErrorMessage("githubUsername config property missing.")
if (githubUsername === undefined || githubUsername === "") {
node.payload.uiObject.setErrorMessage("githubUsername config property missing.")
return
}
let userProfile = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(
node,
'User Profile',
UI.projects.foundations.spaces.designSpace.workspace.workspaceNode.rootNodes
)
createNewAccount()
function createNewAccount() {
@@ -62,7 +64,7 @@ function newGovernanceFunctionLibraryProfileConstructor() {
params: {
method: "signData",
privateKey: privateKey,
data: data
data: githubUsername
}
}
@@ -83,11 +85,25 @@ function newGovernanceFunctionLibraryProfileConstructor() {
console.log('Call to WEB3 Server failed. ' + response.error)
return
}
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(node.payload.referenceParent.payload, 'signature', response.signature)
/*
We store at the User Profile the Signed githubUsername
*/
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(userProfile.payload, 'signature', response.signature)
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(node.payload, 'address', address)
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(node.payload, 'privateKey', privateKey)
node.payload.uiObject.setInfoMessage("Profile Account has been successfully created.")
/*
We set the name of the User Profile as the githubUsername
*/
userProfile.name = githubUsername
/*
We also Install the User Profile as a Plugin, which in turns saves it.
*/
userProfile.payload.uiObject.menu.internalClick('Install as Plugin')
userProfile.payload.uiObject.menu.internalClick('Install as Plugin')
/*
Show nice message.
*/
node.payload.uiObject.setInfoMessage("Profile Private Key has been successfully created. User Profile installed as a plugin and saved. Use the Private Key at a crypto wallet and delete this node once done.", 10000)
}
}
}