Signing Account Feature Improved

This commit is contained in:
Luis Fernando Molina committed 2021-10-22 13:45:33 +02:00
1 parent 5c9597950b
commit 1326aed521
13 files changed
+1049 -721

No files matched your search

@@ -126,12 +126,12 @@
"id": "68dd2990-457e-48df-b752-6e1fd02081a3",
"savedPayload": {
"position": {
"x": 21874.39317393575,
"y": 44873.02143806756
"x": 21287.42951326449,
"y": 44555.94024882619
},
"targetPosition": {
"x": 21882.246258428113,
"y": 45172.91863556023
"x": 21569.464995635255,
"y": 44658.19476796295
},
"floatingObject": {
"isPinned": false,
@@ -247,12 +247,12 @@
"id": "21bdec2e-d471-4b64-a3e0-6e2b31c5adcc",
"savedPayload": {
"position": {
"x": 21989.756643291705,
"y": 44892.844507611066
"x": 21348.029296389053,
"y": 44455.79360418333
},
"targetPosition": {
"x": 21882.246258428113,
"y": 45172.91863556023
"x": 21569.464995635255,
"y": 44658.19476796295
},
"floatingObject": {
"isPinned": false,
@@ -368,12 +368,12 @@
"id": "ffe4621a-a216-412f-a9be-354f30f6d102",
"savedPayload": {
"position": {
"x": 22088.752631136238,
"y": 44955.30632425654
"x": 21442.34065740424,
"y": 44386.46070195479
},
"targetPosition": {
"x": 21882.246258428113,
"y": 45172.91863556023
"x": 21569.464995635255,
"y": 44658.19476796295
},
"floatingObject": {
"isPinned": false,
@@ -489,12 +489,12 @@
"id": "96e5c443-f932-47e4-9e5d-48e986dcc637",
"savedPayload": {
"position": {
"x": 22156.309895720893,
"y": 45050.89764263749
"x": 21556.0055465301,
"y": 44358.496848000555
},
"targetPosition": {
"x": 21882.246258428113,
"y": 45172.91863556023
"x": 21569.464995635255,
"y": 44658.19476796295
},
"floatingObject": {
"isPinned": false,
@@ -610,12 +610,12 @@
"id": "a0f8d421-8864-44ac-8922-5d13176abb54",
"savedPayload": {
"position": {
"x": 22182.14345592078,
"y": 45165.06555106787
"x": 21671.719514772012,
"y": 44376.159285592184
},
"targetPosition": {
"x": 21882.246258428113,
"y": 45172.91863556023
"x": 21569.464995635255,
"y": 44658.19476796295
},
"floatingObject": {
"isPinned": false,
@@ -731,12 +731,12 @@
"id": "39e7f6fd-1faa-47e9-862d-45a8482a558a",
"savedPayload": {
"position": {
"x": 22162.320386377272,
"y": 45280.42902042382
"x": 21771.866159414876,
"y": 44436.75906871675
},
"targetPosition": {
"x": 21882.246258428113,
"y": 45172.91863556023
"x": 21569.464995635255,
"y": 44658.19476796295
},
"floatingObject": {
"isPinned": false,
@@ -852,12 +852,12 @@
"id": "0a5a7864-efff-4715-a435-f4bf35d1517e",
"savedPayload": {
"position": {
"x": 22099.858569731798,
"y": 45379.42500826836
"x": 21841.199061643412,
"y": 44531.07042973194
},
"targetPosition": {
"x": 21882.246258428113,
"y": 45172.91863556023
"x": 21569.464995635255,
"y": 44658.19476796295
},
"floatingObject": {
"isPinned": false,
@@ -1004,12 +1004,12 @@
"id": "0e8d603c-081f-4510-917c-34cf9a6ceb4b",
"savedPayload": {
"position": {
"x": 22153.2280717391,
"y": 45193.92142522379
"x": 21688.016714441055,
"y": 44413.61809228199
},
"targetPosition": {
"x": 21901.626901355474,
"y": 45357.3131357283
"x": 21748.193539176038,
"y": 44707.52071180896
},
"floatingObject": {
"isPinned": false,
@@ -1125,12 +1125,12 @@
"id": "fe061f32-f818-4823-8935-e8abf25d1b59",
"savedPayload": {
"position": {
"x": 22195.071181575615,
"y": 45419.686642973626
"x": 21913.462633611667,
"y": 44457.14873569257
},
"targetPosition": {
"x": 21901.626901355474,
"y": 45357.3131357283
"x": 21748.193539176038,
"y": 44707.52071180896
},
"floatingObject": {
"isPinned": false,
@@ -1246,12 +1246,12 @@
"id": "24ee5cf0-650a-4bd7-8d8c-904264e54b02",
"savedPayload": {
"position": {
"x": 22065.01861185998,
"y": 45608.914306111925
"x": 22042.096158703007,
"y": 44647.34388707398
},
"targetPosition": {
"x": 21901.626901355474,
"y": 45357.3131357283
"x": 21748.193539176038,
"y": 44707.52071180896
},
"floatingObject": {
"isPinned": false,
@@ -1398,12 +1398,12 @@
"id": "eb50e1af-b356-419a-a848-43e3fa43bfa8",
"savedPayload": {
"position": {
"x": 22009.66098495065,
"y": 45740.826523769414
"x": 22144.66536712425,
"y": 44747.06779347655
},
"targetPosition": {
"x": 21808.92180304299,
"y": 45517.88307612619
"x": 21863.79490593233,
"y": 44852.48024070095
},
"floatingObject": {
"isPinned": false,
@@ -1550,12 +1550,12 @@
"id": "2242950f-bf22-4843-a8ea-e8d61339c362",
"savedPayload": {
"position": {
"x": 21815.876735803373,
"y": 45836.00129540594
"x": 22180.602827038594,
"y": 45085.602082425416
},
"targetPosition": {
"x": 21639.54116011563,
"y": 45593.296197093456
"x": 21882.246258428113,
"y": 45116.96062140571
},
"floatingObject": {
"isPinned": false,
@@ -1671,12 +1671,12 @@
"id": "aff3a589-27aa-4a84-92a7-c25919a33c70",
"savedPayload": {
"position": {
"x": 21517.52016719289,
"y": 45867.35983438624
"x": 22058.581834115856,
"y": 45359.6657197182
},
"targetPosition": {
"x": 21639.54116011563,
"y": 45593.296197093456
"x": 21882.246258428113,
"y": 45116.96062140571
},
"floatingObject": {
"isPinned": false,
@@ -1705,7 +1705,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"isCollapsed": false,
"angleToParent": 2,
"distanceToParent": 3,
"arrangementStyle": 0
@@ -1729,7 +1729,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": true,
"isCollapsed": false,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
@@ -4102,12 +4102,12 @@
"id": "dc148eee-1c57-48be-918e-5c91d3b2a1ee",
"savedPayload": {
"position": {
"x": 21314.99425281151,
"y": 46057.29874664579
"x": 20461.63031479918,
"y": 45484.235522592324
},
"targetPosition": {
"x": 21098.932678850673,
"y": 45849.17042983723
"x": 20576.435344508704,
"y": 45207.071662838935
},
"floatingObject": {
"isPinned": false,
@@ -4132,12 +4132,12 @@
"id": "5177790d-4a5f-4873-b25f-b727729c53a5",
"savedPayload": {
"position": {
"x": 21218.900286146596,
"y": 46124.139106598224
"x": 20364.30331015274,
"y": 45419.2036971949
},
"targetPosition": {
"x": 21098.932678850673,
"y": 45849.17042983723
"x": 20576.435344508704,
"y": 45207.071662838935
},
"floatingObject": {
"isPinned": false,
@@ -4162,12 +4162,12 @@
"id": "f6494f82-4e9a-4962-a111-f75763f66bff",
"savedPayload": {
"position": {
"x": 21104.542338779946,
"y": 46149.117978111055
"x": 20299.271484755318,
"y": 45321.87669254846
},
"targetPosition": {
"x": 21098.932678850673,
"y": 45849.17042983723
"x": 20576.435344508704,
"y": 45207.071662838935
},
"floatingObject": {
"isPinned": false,
@@ -4187,12 +4187,12 @@
"id": "d845296c-a4c9-43a1-9fcd-f63678d09649",
"savedPayload": {
"position": {
"x": 21098.932678850673,
"y": 45849.17042983723
"x": 20576.435344508704,
"y": 45207.071662838935
},
"targetPosition": {
"x": 20978.96507155475,
"y": 45574.20175307623
"x": 20788.567378864667,
"y": 44994.93962848297
},
"floatingObject": {
"isPinned": false,
@@ -4223,12 +4223,12 @@
"id": "71389baa-502a-4df3-bed5-66618ccb5495",
"savedPayload": {
"position": {
"x": 20874.972424174106,
"y": 46153.41142594332
"x": 20211.40351911128,
"y": 45109.744658192496
},
"targetPosition": {
"x": 20869.362764244834,
"y": 45853.46387766949
"x": 20488.567378864667,
"y": 44994.93962848297
},
"floatingObject": {
"isPinned": false,
@@ -4253,12 +4253,12 @@
"id": "b756d2de-2a22-421a-840c-629646e8851b",
"savedPayload": {
"position": {
"x": 20759.760456934917,
"y": 46132.72600226275
"x": 20188.567378864667,
"y": 44994.93962848297
},
"targetPosition": {
"x": 20869.362764244834,
"y": 45853.46387766949
"x": 20488.567378864667,
"y": 44994.93962848297
},
"floatingObject": {
"isPinned": false,
@@ -4283,12 +4283,12 @@
"id": "90877e7d-cce4-475b-864b-9ec29fd6c5e3",
"savedPayload": {
"position": {
"x": 20661.234447436273,
"y": 46069.52545163033
"x": 20211.40351911128,
"y": 44880.134598773446
},
"targetPosition": {
"x": 20869.362764244834,
"y": 45853.46387766949
"x": 20488.567378864667,
"y": 44994.93962848297
},
"floatingObject": {
"isPinned": false,
@@ -4308,12 +4308,12 @@
"id": "edf5afb0-79ff-4a19-98af-8001f118b735",
"savedPayload": {
"position": {
"x": 20869.362764244834,
"y": 45853.46387766949
"x": 20488.567378864667,
"y": 44994.93962848297
},
"targetPosition": {
"x": 20978.96507155475,
"y": 45574.20175307623
"x": 20788.567378864667,
"y": 44994.93962848297
},
"floatingObject": {
"isPinned": false,
@@ -4344,12 +4344,12 @@
"id": "1484266d-df06-4a29-bba6-53e296f8ba3f",
"savedPayload": {
"position": {
"x": 20495.868077985197,
"y": 45910.23093433299
"x": 20299.271484755318,
"y": 44668.00256441748
},
"targetPosition": {
"x": 20703.996394793758,
"y": 45694.16936037215
"x": 20576.435344508704,
"y": 44782.80759412701
},
"floatingObject": {
"isPinned": false,
@@ -4374,12 +4374,12 @@
"id": "21d0d5bf-a5ff-473b-9913-ccf80a136aa6",
"savedPayload": {
"position": {
"x": 20429.027718032765,
"y": 45814.13696766807
"x": 20364.30331015274,
"y": 44570.67555977104
},
"targetPosition": {
"x": 20703.996394793758,
"y": 45694.16936037215
"x": 20576.435344508704,
"y": 44782.80759412701
},
"floatingObject": {
"isPinned": false,
@@ -4404,12 +4404,12 @@
"id": "05c32139-e3ba-460c-8837-24d002892f2b",
"savedPayload": {
"position": {
"x": 20404.048846519934,
"y": 45699.77902030142
"x": 20461.63031479918,
"y": 44505.64373437362
},
"targetPosition": {
"x": 20703.996394793758,
"y": 45694.16936037215
"x": 20576.435344508704,
"y": 44782.80759412701
},
"floatingObject": {
"isPinned": false,
@@ -4429,12 +4429,12 @@
"id": "b779f4a3-91c0-419c-b41b-d264c0e6b055",
"savedPayload": {
"position": {
"x": 20703.996394793758,
"y": 45694.16936037215
"x": 20576.435344508704,
"y": 44782.80759412701
},
"targetPosition": {
"x": 20978.96507155475,
"y": 45574.20175307623
"x": 20788.567378864667,
"y": 44994.93962848297
},
"floatingObject": {
"isPinned": false,
@@ -4496,12 +4496,12 @@
"id": "8f1453bd-7df3-433b-9c09-9645f3010bad",
"savedPayload": {
"position": {
"x": 20523.648020938374,
"y": 45975.72061436919
"x": 20550.561376777296,
"y": 44292.69595750969
},
"targetPosition": {
"x": 20648.736255766773,
"y": 45703.04327114552
"x": 20788.567378864667,
"y": 44475.324386212305
},
"floatingObject": {
"isPinned": false,
@@ -4526,12 +4526,12 @@
"id": "3c25bc31-19a1-4a11-90d6-ab1507499c46",
"savedPayload": {
"position": {
"x": 20428.820694217826,
"y": 45907.0950924768
"x": 20638.567378864667,
"y": 44215.51676507697
},
"targetPosition": {
"x": 20648.736255766773,
"y": 45703.04327114552
"x": 20788.567378864667,
"y": 44475.324386212305
},
"floatingObject": {
"isPinned": false,
@@ -4556,12 +4556,12 @@
"id": "ae537189-a6ff-470a-9f15-2425160f4d47",
"savedPayload": {
"position": {
"x": 20367.473518203573,
"y": 45807.40453052109
"x": 20749.409521198653,
"y": 44177.89092780016
},
"targetPosition": {
"x": 20648.736255766773,
"y": 45703.04327114552
"x": 20788.567378864667,
"y": 44475.324386212305
},
"floatingObject": {
"isPinned": false,
@@ -4581,12 +4581,12 @@
"id": "845ddcca-fadb-4a8e-9f2a-03cb9cbfb99a",
"savedPayload": {
"position": {
"x": 20648.736255766773,
"y": 45703.04327114552
"x": 20788.567378864667,
"y": 44475.324386212305
},
"targetPosition": {
"x": 20868.65181731572,
"y": 45498.991449814246
"x": 20938.567378864667,
"y": 44735.13200734764
},
"floatingObject": {
"isPinned": false,
@@ -4688,7 +4688,7 @@
"floatingObject": {
"isPinned": false,
"isFrozen": false,
"isCollapsed": false,
"isCollapsed": true,
"angleToParent": 1,
"distanceToParent": 3,
"arrangementStyle": 0
File diff suppressed because it is too large. Load diff
@@ -33,5 +33,5 @@
"compatibleTypes": "->Signing Account->"
},
"childrenNodesProperties": [],
"propertyNameAtParent": "assignedTo"
"propertyNameAtParent": "signingAccountChild"
}
@@ -25,7 +25,7 @@
"config": true
},
"initialValues": {
"config": "{ \n\"host\": \"localhost\", \n\"webPort\": \"34248\", \n\"webSocketsPort\": \"18041\"\n}"
"config": "{ \n\"codeName\": \"localhost\", \n\"host\": \"localhost\", \n\"webSocketsPort\": \"18042\"\n}"
},
"addLeftIcons": true,
"level": 1,
@@ -33,5 +33,5 @@
"compatibleTypes": "->Signing Account->"
},
"childrenNodesProperties": [],
"propertyNameAtParent": "assignedTo"
"propertyNameAtParent": "signingAccountChild"
}
@@ -20,9 +20,53 @@
"relatedUiObjectProject": "Governance"
},
{
"action": "Add Signing Account",
"action": "Add Social Trading Desktop App",
"actionProject": "Governance",
"label": "Add Signing Account",
"label": "Add Social Trading Desktop App",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
"relatedUiObject": "Profile Constructor",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Add Social Trading Server App",
"actionProject": "Governance",
"label": "Add Social Trading Server App",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
"relatedUiObject": "Profile Constructor",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Add Social Trading Mobile App",
"actionProject": "Governance",
"label": "Add Social Trading Mobile App",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
"relatedUiObject": "Profile Constructor",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Add Algo Traders Platform",
"actionProject": "Governance",
"label": "Add Algo Traders Platform",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
"relatedUiObject": "Profile Constructor",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Add P2P Network Node",
"actionProject": "Governance",
"label": "Add P2P Network Node",
"askConfirmation": true,
"confirmationLabel": "Confirm to Proceed",
"workDoneLabel": "Done",
@@ -9,56 +9,6 @@
"iconPathOn": "configuration",
"iconPathOff": "configuration"
},
{
"action": "Add UI Object",
"actionProject": "Visual-Scripting",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "assignedTo",
"label": "Add P2P Network Node",
"relatedUiObject": "P2P Network Node",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Network"
},
{
"action": "Add UI Object",
"actionProject": "Visual-Scripting",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "assignedTo",
"label": "Add Algo Traders Platform",
"relatedUiObject": "Algo Traders Platform",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Add UI Object",
"actionProject": "Visual-Scripting",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "assignedTo",
"label": "Add Social Trading Mobile App",
"relatedUiObject": "Social Trading Mobile App",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Add UI Object",
"actionProject": "Visual-Scripting",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "assignedTo",
"label": "Add Social Trading Desktop App",
"relatedUiObject": "Social Trading Desktop App",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Add UI Object",
"actionProject": "Visual-Scripting",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "assignedTo",
"label": "Add Social Trading Server App",
"relatedUiObject": "Social Trading Server App",
"actionFunction": "payload.executeAction",
"relatedUiObjectProject": "Governance"
},
{
"action": "Delete UI Object",
"actionProject": "Visual-Scripting",
@@ -84,31 +34,31 @@
"propertyNameAtParent": "signingAccounts",
"childrenNodesProperties": [
{
"name": "assignedTo",
"name": "signingAccountChild",
"type": "node",
"childType": "P2P Network Node",
"autoAdd": false
},
{
"name": "assignedTo",
"name": "signingAccountChild",
"type": "node",
"childType": "Algo Traders Platform",
"autoAdd": false
},
{
"name": "assignedTo",
"name": "signingAccountChild",
"type": "node",
"childType": "Social Trading Mobile App",
"autoAdd": false
},
{
"name": "assignedTo",
"name": "signingAccountChild",
"type": "node",
"childType": "Social Trading Desktop App",
"autoAdd": false
},
{
"name": "assignedTo",
"name": "signingAccountChild",
"type": "node",
"childType": "Social Trading Server App",
"autoAdd": false
@@ -33,5 +33,5 @@
"compatibleTypes": "->Signing Account->"
},
"childrenNodesProperties": [],
"propertyNameAtParent": "assignedTo"
"propertyNameAtParent": "signingAccountChild"
}
@@ -33,5 +33,5 @@
"compatibleTypes": "->Signing Account->"
},
"childrenNodesProperties": [],
"propertyNameAtParent": "assignedTo"
"propertyNameAtParent": "signingAccountChild"
}
@@ -33,5 +33,5 @@
"compatibleTypes": "->Signing Account->"
},
"childrenNodesProperties": [],
"propertyNameAtParent": "assignedTo"
"propertyNameAtParent": "signingAccountChild"
}
@@ -38,9 +38,29 @@ function newGovernanceActionSwitch() {
UI.projects.governance.functionLibraries.profileConstructor.buildProfile(action.node, action.rootNodes)
break
}
case 'Add Signing Account':
case 'Add Social Trading Desktop App':
{
UI.projects.governance.functionLibraries.profileConstructor.addSigningAccount(action.node, action.rootNodes)
UI.projects.governance.functionLibraries.profileConstructor.addSigningAccount(action.node, action.rootNodes, 'Social Trading Desktop App')
break
}
case 'Add Social Trading Server App':
{
UI.projects.governance.functionLibraries.profileConstructor.addSigningAccount(action.node, action.rootNodes, 'Social Trading Server App')
break
}
case 'Add Social Trading Mobile App':
{
UI.projects.governance.functionLibraries.profileConstructor.addSigningAccount(action.node, action.rootNodes, 'Social Trading Mobile App')
break
}
case 'Add Algo Traders Platform':
{
UI.projects.governance.functionLibraries.profileConstructor.addSigningAccount(action.node, action.rootNodes, 'Algo Traders Platform')
break
}
case 'Add P2P Network Node':
{
UI.projects.governance.functionLibraries.profileConstructor.addSigningAccount(action.node, action.rootNodes, 'P2P Network Node')
break
}
case 'Add Missing Plugin User Profiles':
@@ -68,7 +88,7 @@ function newGovernanceActionSwitch() {
UI.projects.governance.functionLibraries.pluginsFunctions.addMissingPluginPositions(action.node, action.rootNodes)
}
break
default: {
console.log("[WARN] Action sent to Governance Action Switch does not belong here. Verify at the App Schema file of the node that triggered this action that the actionProject is pointing to the right project. -> Action = " + action.name + " -> Action Node Name = " + action.node.name)
}
@@ -159,7 +159,8 @@ function newGovernanceFunctionLibraryProfileConstructor() {
function addSigningAccount(
node,
rootNodes
rootNodes,
targetNodeType
) {
let githubUsername = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(node.payload, 'githubUsername')
let mnemonic = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(node.payload, 'mnemonic')
@@ -299,20 +300,48 @@ function newGovernanceFunctionLibraryProfileConstructor() {
'Signing Account',
UI.projects.foundations.spaces.designSpace.workspace.workspaceNode.rootNodes
)
let signingAccountChild = UI.projects.visualScripting.functionLibraries.uiObjectsFromNodes.addUIObject(
signingAccount,
targetNodeType,
UI.projects.foundations.spaces.designSpace.workspace.workspaceNode.rootNodes
)
/*
Let's get a cool name for this node.
*/
let targetNodeTypeCount = 0
for (let i = 0; i < signingAccounts.signingAccounts.length; i++) {
let singningAccount = signingAccounts.signingAccounts[i]
if (singningAccount.signingAccountChild.type === targetNodeType) {
targetNodeTypeCount++
}
}
signingAccountChild.name = targetNodeType +" # " + targetNodeTypeCount
let codeName = targetNodeType.replaceAll(' ', '-') + "-" + targetNodeTypeCount
/*
We store at the User Profile the Signed githubUsername
*/
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(signingAccountChild.payload, 'codeName', codeName)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(signingAccount.payload, 'signature', signature)
node.config = "{}"
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'nodeName', signingAccount.name)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'codeName', signingAccount.name)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'nodeType', signingAccount.type)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'nodeId', signingAccount.id)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'address', address)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'privateKey', privateKey)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'githubUsername', githubUsername)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'userProfileId', node.payload.referenceParent.id)
let secrets = UI.projects.visualScripting.utilities.nodeConfig.loadConfigProperty(node.payload, 'secrets', signingAccount.name)
if (secrets === undefined) {
secrets = []
}
let secret = {
signingAccountChildName: signingAccountChild.name,
signingAccountChildType: targetNodeType,
signingAccountChildCodeName: codeName,
signingAccountNodeId: signingAccount.id,
privateKey: privateKey,
userProfileHandle: githubUsername,
userProfileId: node.payload.referenceParent.id
}
secrets.push(secret)
UI.projects.visualScripting.utilities.nodeConfig.saveConfigProperty(node.payload, 'secrets', secrets)
/*
Show nice message.
*/
@@ -0,0 +1,269 @@
exports.newNetworkModulesWebSocketsNetworkClient = function newNetworkModulesWebSocketsNetworkClient() {
let thisObject = {
sendMessage: sendMessage,
initialize: initialize,
finalize: finalize
}
let socketClient
let web3
let called = {}
let selectedNetworkNode // This is a Network Node we pick to try to connect to.
let onMessageFunctionsMap = new Map()
return thisObject
function finalize() {
socketClient.close()
socketClient = undefined
networkInterface = undefined
peerInterface = undefined
web3 = undefined
called = undefined
onMessageFunctionsMap = undefined
}
async function initialize() {
/*
Here we will pick a Network Node from all users profiles available that do have a Network Node running. // TODO
In the meantime, we will assume that we have chosen the following Network Node to connect to.
*/
web3 = new SA.nodeModules.web3()
selectedNetworkNode = {
userProfileHandle: "Luis-Fernando-Molina",
blockchainAccount: "0xeBDCB7a73c4796ca9F025d005630eCe773dd9e54",
ranking: 0,
host: "localhost",
port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT
}
socketClient = new SA.nodeModules.ws('ws://' + selectedNetworkNode.host + ':' + selectedNetworkNode.port)
await setUpWebsocketClient()
}
async function setUpWebsocketClient() {
return new Promise(connectToNewtwork)
function connectToNewtwork(resolve, reject) {
try {
socketClient.onopen = () => { onConnection() }
socketClient.onerror = err => { onError(err) }
function onConnection() {
handshakeProcedure()
function handshakeProcedure() {
let callerTimestamp
stepOneRequest()
function stepOneRequest() {
/*
Send Handshake Message Step One:
At Step One we will just say hello, identify ourselves
as a Network Client, and send the Network Node our
User Profile Handle.
This Handle will be signed by the Network Node to prove
it's ouwn identity, and later we will sign it's own handle
to prove ours.
*/
socketClient.onmessage = socketMessage => { stepOneResponse(socketMessage) }
callerTimestamp = (new Date()).valueOf()
let message = {
messageType: 'Handshake',
callerRole: 'Network Node',
callerProfileHandle: SA.secrets.map.get('Social Trading Desktop').githubUsername,
callerTimestamp: callerTimestamp,
step: 'One'
}
socketClient.send(JSON.stringify(message))
}
function stepOneResponse(socketMessage) {
let response = JSON.parse(socketMessage.data)
if (response.result !== 'Ok') {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> response.message = ' + response.message)
reject()
return
}
let signature = JSON.parse(response.signature)
called.blockchainAccount = web3.eth.accounts.recover(signature)
/*
We will check that the signature received produces a valid Blockchain Account.
*/
if (called.blockchainAccount === undefined) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> Signature does not produce a valid Blockchain Account.')
reject()
return
}
/*
We will check that the blockchain account taken from the signature matches
the one we have on record for the user profile of the Network Node we are calling.
*/
if (called.blockchainAccount !== selectedNetworkNode.blockchainAccount) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> The Network Node called does not have the expected Profile Handle.')
reject()
return
}
let signedMessage = JSON.parse(signature.message)
/*
We will verify that the signature belongs to the signature.message.
To do this we will hash the signature.message and see if we get
the same hash of the signature.
*/
let hash = web3.eth.accounts.hashMessage(signature.message)
if (hash !== signature.messageHash) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> signature.message Hashed Does Not Match signature.messageHash.')
reject()
return
}
/*
We will check that the Network Node that responded has the same User Profile Handle
that we have on record, otherwise something is wrong and we should not proceed.
*/
if (signedMessage.calledProfileHandle !== selectedNetworkNode.userProfileHandle) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> The Network Node called does not have the expected Profile Handle.')
reject()
return
}
/*
We will check that the profile handle we sent to the Network Node, is returned at the
signed message, to avoid man in the middle attackts.
*/
if (signedMessage.callerProfileHandle !== SA.secrets.map.get('Social Trading Desktop').githubUsername) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> The Network Node callerProfileHandle does not match my own userProfileHandle.')
reject()
return
}
/*
We will also check that the callerTimestamp we sent to the Network Node, is returned at the
signed message, also to avoid man in the middle attackts.
*/
if (signedMessage.callerTimestamp !== callerTimestamp) {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> The Network Node callerTimestamp does not match my own callerTimestamp.')
reject()
return
}
/*
All validations passed, it seems we can continue with Step Two.
*/
stepTwoRequest(signedMessage)
}
function stepTwoRequest(signedMessage) {
/*
Send Handshake Message Step Two:
Here we will sign a message with the Network Node profile
handle and timestamp to prove our own identity.
*/
socketClient.onmessage = socketMessage => { stepTwoResponse(socketMessage) }
let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), SA.secrets.map.get('Social Trading Desktop').privateKey)
let message = {
messageType: 'Handshake',
signature: JSON.stringify(signature),
step: 'Two'
}
socketClient.send(JSON.stringify(message))
}
function stepTwoResponse(socketMessage) {
let response = JSON.parse(socketMessage.data)
if (response.result !== 'Ok') {
console.log('[ERROR] Web Sockets Client -> stepOneResponse -> response.message = ' + response.message)
reject()
return
}
/*
This was the end of the Handshake producere. We are connected to the
Network Node and from now on, all response messages will be received
at this following function.
*/
socketClient.onmessage = socketMessage => { onMenssage(socketMessage) }
resolve()
}
}
}
function onError(err) {
console.log('[ERROR] Web Sockets Client -> onError -> err.message = ' + err.message)
console.log('[ERROR] Web Sockets Client -> onError -> err.stack = ' + err.stack)
}
} catch (err) {
console.log('[ERROR] Web Sockets Client -> setUpWebsocketClient -> err.stack = ' + err.stack)
}
}
}
function sendMessage(message) {
return new Promise(sendSocketMessage)
function sendSocketMessage(resolve, reject) {
if (socketClient.readyState !== 1) { // 1 means connected and ready.
console.log('[ERROR] Web Sockets Client -> sendMessage -> Cannot send message while connection is closed.')
reject('Websockets Connection Not Ready.')
return
}
let socketMessage = {
messageId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
messageType: 'Request',
payload: message
}
onMessageFunctionsMap.set(socketMessage.messageId, onMenssageFunction)
socketClient.send(
JSON.stringify(socketMessage)
)
function onMenssageFunction(response) {
try {
if (response.result === 'Ok') {
resolve(response.data)
} else {
console.log('[ERROR] Web Sockets Client -> onMenssageFunction -> response.message = ' + response.message)
reject(response.message)
}
} catch (err) {
callbackFunction = undefined
console.log('[ERROR] Web Sockets Client -> err.stack = ' + err.stack)
}
}
}
}
function onMenssage(socketMessage) {
let response = JSON.parse(socketMessage.data)
/*
We get the functioin that is going to resolve or reject the promise given.
*/
onMenssageFunction = onMessageFunctionsMap.get(response.messageId)
onMessageFunctionsMap.delete(response.messageId)
onMenssageFunction(response)
}
}
+6
View File
@@ -1357,6 +1357,12 @@
"propertyName": "webSocketsInterface",
"functionName": "newNetworkModulesWebSocketsInterface",
"fileName": "WebSocketsInterface.js"
},
{
"name": "Web Sockets Network Client",
"propertyName": "webSocketsNetworkClient",
"functionName": "newNetworkModulesWebSocketsNetworkClient",
"fileName": "WebSocketsNetworkClient.js"
}
],
"utilities": []