Signing Accounts Created
This commit is contained in:
1 parent
553669f460
commit
f9ac2761d2
13 files changed
+234
-12
No files matched your search
@@ -138,7 +138,7 @@ function newAppLoader() {
|
||||
|
||||
for (let i = 0; i < modulesArray.length; i++) {
|
||||
let path = modulesArray[i]
|
||||
console.log(path)
|
||||
|
||||
REQUIREJS([path], onRequired)
|
||||
|
||||
if (INFO_LOG === true) { logger.write('[INFO] loadModules -> Module Requested.') }
|
||||
|
||||
@@ -98,6 +98,9 @@ function newUniqueId () {
|
||||
|
||||
function splitTextIntoPhrases (text, wordsPerLine) {
|
||||
try {
|
||||
if (text.split === undefined) {
|
||||
return []
|
||||
}
|
||||
let splittedLabel = text.split(' ')
|
||||
let phrases = []
|
||||
let phrase = ''
|
||||
|
||||
@@ -18,6 +18,7 @@ function newWorkspace() {
|
||||
share: shareWorkspace,
|
||||
getNodesByTypeAndHierarchyHeadsType: getNodesByTypeAndHierarchyHeadsType,
|
||||
getProjectsHeads: getProjectsHeads,
|
||||
getProjectHeadByNodeType: getProjectHeadByNodeType,
|
||||
getHierarchyHeads: getHierarchyHeads,
|
||||
getHierarchyHeadsById: getHierarchyHeadsById,
|
||||
getHierarchyHeadsByCodeNameAndNodeType: getHierarchyHeadsByCodeNameAndNodeType,
|
||||
@@ -547,6 +548,17 @@ function newWorkspace() {
|
||||
return nodes
|
||||
}
|
||||
|
||||
function getProjectHeadByNodeType(nodeType) {
|
||||
let projectHeads = getProjectsHeads()
|
||||
if (projectHeads === undefined) { return }
|
||||
for (let i = 0; i < projectHeads.length; i++) {
|
||||
let hierarchyHead = projectHeads[i]
|
||||
if (hierarchyHead.type === nodeType) {
|
||||
return hierarchyHead
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getHierarchyHeadsById(nodeId) {
|
||||
let hierarchyHeads = getHierarchyHeads()
|
||||
if (hierarchyHeads === undefined) { return }
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -18,6 +18,16 @@
|
||||
"relatedUiObject": "Profile Constructor",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Add Signing Account",
|
||||
"actionProject": "Governance",
|
||||
"label": "Add Signing Account",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Proceed",
|
||||
"workDoneLabel": "Done",
|
||||
"relatedUiObject": "Profile Constructor",
|
||||
"actionFunction": "payload.executeAction"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"actionProject": "Foundations",
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
"type": "Signing Account",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Configure",
|
||||
"actionFunction": "uiObject.configEditor.activate",
|
||||
"actionProject": "Foundations",
|
||||
"label": "Configure",
|
||||
"iconPathOn": "configuration",
|
||||
"iconPathOff": "configuration"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"actionProject": "Foundations",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Delete",
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
}
|
||||
],
|
||||
"addLeftIcons": true,
|
||||
"level": 2,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->User Profile->"
|
||||
},
|
||||
"editors": {
|
||||
"config": true
|
||||
},
|
||||
"initialValues": {
|
||||
"config": "{}"
|
||||
},
|
||||
"propertyNameAtParent": "signingAccount"
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"type": "Signing Accounts",
|
||||
"menuItems": [
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"actionProject": "Foundations",
|
||||
"askConfirmation": true,
|
||||
"confirmationLabel": "Confirm to Delete",
|
||||
"label": "Delete",
|
||||
"iconPathOn": "delete-entity",
|
||||
"iconPathOff": "delete-entity",
|
||||
"actionFunction": "payload.executeAction"
|
||||
}
|
||||
],
|
||||
"addLeftIcons": true,
|
||||
"level": 2,
|
||||
"attachingRules": {
|
||||
"compatibleTypes": "->User Profile->"
|
||||
},
|
||||
"propertyNameAtParent": "signingAccounts",
|
||||
"childrenNodesProperties": [
|
||||
{
|
||||
"name": "signingAccounts",
|
||||
"type": "array",
|
||||
"childType": "Signing Account",
|
||||
"autoAdd": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -69,6 +69,12 @@
|
||||
"type": "node",
|
||||
"childType": "Tokens Mined",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "signingAccounts",
|
||||
"type": "node",
|
||||
"childType": "Signing Accounts",
|
||||
"autoAdd": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -38,6 +38,11 @@ function newGovernanceActionSwitch() {
|
||||
UI.projects.governance.functionLibraries.profileConstructor.buildProfile(action.node, action.rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Add Signing Account':
|
||||
{
|
||||
UI.projects.governance.functionLibraries.profileConstructor.addSigningAccount(action.node, action.rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Add Missing Plugin User Profiles':
|
||||
{
|
||||
UI.projects.governance.functionLibraries.pluginsFunctions.addMissingPluginUserProfiles(action.node, action.rootNodes)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
function newGovernanceFunctionLibraryProfileConstructor() {
|
||||
let thisObject = {
|
||||
buildProfile: buildProfile
|
||||
buildProfile: buildProfile,
|
||||
addSigningAccount: addSigningAccount
|
||||
}
|
||||
|
||||
return thisObject
|
||||
@@ -18,7 +19,7 @@ function newGovernanceFunctionLibraryProfileConstructor() {
|
||||
if (githubUsername === undefined || githubUsername === "") {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
"githubUsername config property missing.",
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -53,7 +54,7 @@ function newGovernanceFunctionLibraryProfileConstructor() {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call via HTTP Interface failed.',
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -67,14 +68,14 @@ function newGovernanceFunctionLibraryProfileConstructor() {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call to WEB3 Server failed. ' + response.error,
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
)
|
||||
console.log('Call to WEB3 Server failed. ' + response.error)
|
||||
return
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call to WEB3 Server failed. Most likely the Mnemonic provided is not correct or you need to run node setup because a dependency is missing. ' + response.error,
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
)
|
||||
console.log('Call to WEB3 Server failed. Most likely the Mnemonic provided is not correct or you need to run node setup because a dependency is missing. ' + response.error)
|
||||
return
|
||||
}
|
||||
@@ -103,7 +104,7 @@ function newGovernanceFunctionLibraryProfileConstructor() {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call via HTTP Interface failed.',
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -114,7 +115,7 @@ function newGovernanceFunctionLibraryProfileConstructor() {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call to WEB3 Server failed. ' + response.error,
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
)
|
||||
console.log('Call to WEB3 Server failed. ' + response.error)
|
||||
return
|
||||
}
|
||||
@@ -145,14 +146,130 @@ function newGovernanceFunctionLibraryProfileConstructor() {
|
||||
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.",
|
||||
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR
|
||||
)
|
||||
)
|
||||
} else {
|
||||
node.payload.uiObject.setInfoMessage(
|
||||
"Mnemonic successfully imported. User Profile installed as a plugin and saved. Your external wallet was sucessfully linked to your profile.",
|
||||
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addSigningAccount(
|
||||
node,
|
||||
rootNodes
|
||||
) {
|
||||
let mnemonic = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(node.payload, 'mnemonic')
|
||||
let signingAccounts
|
||||
/*
|
||||
Some validations first...
|
||||
*/
|
||||
if (node.payload.referenceParent === undefined) {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
"The Profile Contstructor needs to reference your User Profile.",
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
if (node.payload.referenceParent.signingAccounts === undefined) {
|
||||
signingAccounts = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(
|
||||
node.payload.referenceParent,
|
||||
'Signing Accounts',
|
||||
UI.projects.foundations.spaces.designSpace.workspace.workspaceNode.rootNodes
|
||||
)
|
||||
} else {
|
||||
signingAccounts = node.payload.referenceParent.signingAccounts
|
||||
}
|
||||
|
||||
createWallet()
|
||||
|
||||
function createWallet() {
|
||||
let params
|
||||
/*
|
||||
If the user provides a mnemonic then we will get the private key and address from it,
|
||||
otherwise, we will create a new private key and address.
|
||||
*/
|
||||
if (mnemonic === undefined || mnemonic === "") {
|
||||
params = {
|
||||
method: 'createWalletAccount',
|
||||
entropy: node.id + (new Date()).valueOf()
|
||||
}
|
||||
} else {
|
||||
params = {
|
||||
method: 'mnemonicToPrivateKey',
|
||||
mnemonic: mnemonic
|
||||
}
|
||||
}
|
||||
|
||||
let url = 'WEB3' // We will access the default Client WEB3 endpoint.
|
||||
|
||||
httpRequest(JSON.stringify(params), 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) {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call via HTTP Interface failed.',
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
let response = JSON.parse(data)
|
||||
|
||||
/* Lets check the result of the method call */
|
||||
if (response.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
|
||||
if (mnemonic === undefined || mnemonic === "") {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call to WEB3 Server failed. ' + response.error,
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
console.log('Call to WEB3 Server failed. ' + response.error)
|
||||
return
|
||||
} else {
|
||||
node.payload.uiObject.setErrorMessage(
|
||||
'Call to WEB3 Server failed. Most likely the Mnemonic provided is not correct or you need to run node setup because a dependency is missing. ' + response.error,
|
||||
UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR
|
||||
)
|
||||
console.log('Call to WEB3 Server failed. Most likely the Mnemonic provided is not correct or you need to run node setup because a dependency is missing. ' + response.error)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
createSigningAccount(response.address, response.privateKey)
|
||||
}
|
||||
}
|
||||
|
||||
function createSigningAccount(address, privateKey) {
|
||||
|
||||
let signingAccount = UI.projects.foundations.functionLibraries.uiObjectsFromNodes.addUIObject(
|
||||
signingAccounts,
|
||||
'Signing Account',
|
||||
UI.projects.foundations.spaces.designSpace.workspace.workspaceNode.rootNodes
|
||||
)
|
||||
/*
|
||||
We store at the User Profile the Signed githubUsername
|
||||
*/
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(signingAccount.payload, 'address', address)
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(node.payload, 'privateKey', privateKey)
|
||||
/*
|
||||
Show nice message.
|
||||
*/
|
||||
if (mnemonic === undefined || mnemonic === "") {
|
||||
node.payload.uiObject.setInfoMessage(
|
||||
"Signing Account has been successfully created.",
|
||||
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR
|
||||
)
|
||||
} else {
|
||||
node.payload.uiObject.setInfoMessage(
|
||||
"Mnemonic successfully imported. Signing Account has been successfully created.",
|
||||
UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,7 @@ function newGovernanceFunctionLibraryTokenMining() {
|
||||
if (userProfile === undefined) { return }
|
||||
if (userProfile.payload === undefined) { return }
|
||||
if (userProfile.tokensMined === undefined) { return }
|
||||
if (userProfile.tokensMined.payload === undefined) { return }
|
||||
if (userProfile.tokensMined.payload.tokensMined === undefined) {
|
||||
userProfile.tokensMined.payload.tokensMined = {
|
||||
awarded: 0,
|
||||
@@ -147,6 +148,8 @@ function newGovernanceFunctionLibraryTokenMining() {
|
||||
if (userProfile === undefined) { return }
|
||||
if (userProfile.payload === undefined) { return }
|
||||
if (userProfile.tokensMined === undefined) { return }
|
||||
if (userProfile.tokensMined.payload === undefined) { return }
|
||||
|
||||
if (programNode.payload === undefined) { return }
|
||||
if (programNode.payload[programPropertyName] === undefined) { return }
|
||||
|
||||
@@ -165,6 +168,7 @@ function newGovernanceFunctionLibraryTokenMining() {
|
||||
if (userProfile === undefined) { return }
|
||||
if (userProfile.payload === undefined) { return }
|
||||
if (userProfile.tokensMined === undefined) { return }
|
||||
if (userProfile.tokensMined.payload === undefined) { return }
|
||||
|
||||
const awarded = parseFloat(userProfile.tokensMined.payload.tokensMined.awarded.toFixed(0)).toLocaleString('en')
|
||||
const bonus = parseFloat(userProfile.tokensMined.payload.tokensMined.bonus.toFixed(0)).toLocaleString('en')
|
||||
|
||||
@@ -26,7 +26,7 @@ function newGovernanceUserProfileSpace() {
|
||||
/*
|
||||
If the workspace is not related to governance, then we exit the Intialize Function
|
||||
*/
|
||||
let governanceProject = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('Governance Project')
|
||||
let governanceProject = UI.projects.foundations.spaces.designSpace.workspace.getProjectHeadByNodeType('Governance Project')
|
||||
if (governanceProject === undefined) { return }
|
||||
/*
|
||||
Here we will run the distribution process, that in turn will run all the programs.
|
||||
@@ -334,12 +334,13 @@ function newGovernanceUserProfileSpace() {
|
||||
/*
|
||||
If the workspace is not related to governance, then we exit the Intialize Function
|
||||
*/
|
||||
let governanceProject = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('Governance Project')
|
||||
let governanceProject = UI.projects.foundations.spaces.designSpace.workspace.getProjectHeadByNodeType('Governance Project')
|
||||
if (governanceProject === undefined) { return }
|
||||
/*
|
||||
Load the user profiles with Token Power.
|
||||
*/
|
||||
let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile')
|
||||
if (waitingForResponses !== 0) { return }
|
||||
/*
|
||||
We will get all the user Profiles tokens from the blockchain, making a call
|
||||
every 5 seconds so as not to exceed the rate limit.
|
||||
|
||||
Reference in new issue
Block a user