diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js index 3c225154c..ea5bceab3 100644 --- a/Desktop/DesktopApp.js +++ b/Desktop/DesktopApp.js @@ -6,21 +6,16 @@ exports.newDesktopApp = function newDesktopApp() { return thisObject - function run() { + async function run() { +/* + let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() + await socialGraphService.initialize() +*/ /* Let's start the Network Interfaces */ DK.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient() DK.webSocketsClient.initialize() - - return - start() - - async function start() { - let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() - await socialGraphService.initialize() - } - } } diff --git a/Projects/Governance/Plugins/User-Profiles/Test-Network-Client-Profile.json b/Projects/Governance/Plugins/User-Profiles/Test-Network-Client-Profile.json new file mode 100644 index 000000000..d8721b28c --- /dev/null +++ b/Projects/Governance/Plugins/User-Profiles/Test-Network-Client-Profile.json @@ -0,0 +1,84 @@ +{ + "type": "User Profile", + "name": "Test-Network-Client-Profile", + "config": "{\n \"signature\": {\n \"message\": \"Test-Network-Client-Profile\",\n \"messageHash\": \"0xd768f828a837f3fa0c3e9bb8090820c415ff08be93cad759a53bc2115487c5d7\",\n \"v\": \"0x1c\",\n \"r\": \"0x1401b80eec441aa9789580848e0179f36485acab9562fe184bca5e2fd9e77887\",\n \"s\": \"0x06400cef3453437805fb9b086c246d7def27a146ed975450edf7dcc46795a57d\",\n \"signature\": \"0x1401b80eec441aa9789580848e0179f36485acab9562fe184bca5e2fd9e7788706400cef3453437805fb9b086c246d7def27a146ed975450edf7dcc46795a57d1c\"\n }\n}", + "project": "Governance", + "tokenPowerSwitch": { + "type": "Token Power Switch", + "name": "New Token Power Switch", + "config": "{}", + "project": "Governance", + "tokenPowerSwitch": [], + "id": "c2a1f8b1-0eb3-457a-9508-2e0c813ced37", + "savedPayload": { + "position": { + "x": 13282, + "y": 11240.5 + }, + "targetPosition": { + "x": 13327, + "y": 11256.5 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "tokensMined": { + "type": "Tokens Mined", + "name": "New Tokens Mined", + "project": "Governance", + "id": "e796be1b-7d10-47f1-8b1a-4d7ce962a113", + "savedPayload": { + "position": { + "x": 13400, + "y": 11204.5 + }, + "targetPosition": { + "x": 13327, + "y": 11256.5 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "id": "baa2f02c-2920-4edb-a103-d452fc61d82f", + "savedPayload": { + "position": { + "x": 13327, + "y": 11256.5 + }, + "targetPosition": { + "x": 13297, + "y": 11290.5 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } +} \ No newline at end of file diff --git a/Projects/Governance/Plugins/User-Profiles/Test-Network-Node-Profile.json b/Projects/Governance/Plugins/User-Profiles/Test-Network-Node-Profile.json new file mode 100644 index 000000000..23fb48537 --- /dev/null +++ b/Projects/Governance/Plugins/User-Profiles/Test-Network-Node-Profile.json @@ -0,0 +1,84 @@ +{ + "type": "User Profile", + "name": "Test-Network-Node-Profile", + "config": "{\n \"signature\": {\n \"message\": \"Test-Network-Node-Profile\",\n \"messageHash\": \"0xa05026b7c6c2a2375480d5d24949621749cc48e461e6e80278a9ef1b6dc7c5f1\",\n \"v\": \"0x1c\",\n \"r\": \"0x8f28f992b0074e4d50007cdfbf18980ca58b4969e04a54d06e4d4798bb982c9a\",\n \"s\": \"0x1c11951a92a1beffe8f3ddd06426ebe1b89875b56d5e374426100d5f59245ea3\",\n \"signature\": \"0x8f28f992b0074e4d50007cdfbf18980ca58b4969e04a54d06e4d4798bb982c9a1c11951a92a1beffe8f3ddd06426ebe1b89875b56d5e374426100d5f59245ea31c\"\n }\n}", + "project": "Governance", + "tokenPowerSwitch": { + "type": "Token Power Switch", + "name": "New Token Power Switch", + "config": "{}", + "project": "Governance", + "tokenPowerSwitch": [], + "id": "11f69cbe-00c8-4fac-9fcc-701a7600c92c", + "savedPayload": { + "position": { + "x": 13516, + "y": 11661 + }, + "targetPosition": { + "x": 13486, + "y": 11579 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "tokensMined": { + "type": "Tokens Mined", + "name": "New Tokens Mined", + "project": "Governance", + "id": "501f456f-b4b5-4b7e-9118-0f26215dd20e", + "savedPayload": { + "position": { + "x": 13470, + "y": 11657 + }, + "targetPosition": { + "x": 13486, + "y": 11579 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "id": "36c2b050-631f-4291-987c-418adc94317d", + "savedPayload": { + "position": { + "x": 13486, + "y": 11579 + }, + "targetPosition": { + "x": 13413, + "y": 11508 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } +} \ No newline at end of file diff --git a/Projects/Network/NT/Modules/WebSocketsInterface.js b/Projects/Network/NT/Modules/WebSocketsInterface.js index 30c56da58..2aafb637c 100644 --- a/Projects/Network/NT/Modules/WebSocketsInterface.js +++ b/Projects/Network/NT/Modules/WebSocketsInterface.js @@ -234,7 +234,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock } let signature = JSON.parse(messageHeader.signature) - let blockchainAccount = web3.eth.accounts.recover(signature) + caller.blockchainAccount = web3.eth.accounts.recover(signature) if (caller.blockchainAccount === undefined) { let response = { @@ -247,7 +247,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock /* The signature gives us the blockchain account, and the account the user profile. */ - let witnessUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount) + let witnessUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.get(caller.blockchainAccount) if (witnessUserProfile === undefined) { let response = { diff --git a/Projects/Network/SA/Modules/WebSocketsClient.js b/Projects/Network/SA/Modules/WebSocketsClient.js index ef4b002bf..d5925aae7 100644 --- a/Projects/Network/SA/Modules/WebSocketsClient.js +++ b/Projects/Network/SA/Modules/WebSocketsClient.js @@ -28,11 +28,15 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets 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. + { + "githubUsername": "Test-Network-Node-Profile", + "address": "0xa153469c57A91F5a59Fc6c45A37aD8dbad85e417" + } */ selectedNetworkNode = { - userProfileId: "qeqdqxex1qexqexqwxeqweqxeqweqe", - userProfileHandle: "Luis-Fernando-Molina", - blockchainAccount: "asdasdasdasdasdasdasdaasdasdasdasdasdasdsd", + userProfileHandle: "Test-Network-Node-Profile", + blockchainAccount: "0xa153469c57A91F5a59Fc6c45A37aD8dbad85e417", ranking: 0, host: "localhost", port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT @@ -80,11 +84,11 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets let message = { messageType: 'Handshake', callerRole: 'Network Client', - userProfileHandle: DK.NETWORK_CLIENT_USER_PROFILE_HANDLE, + callerProfileHandle: DK.TEST_NETWORK_CLIENT_USER_PROFILE_HANDLE, callerTimestamp: callerTimestamp, step: 'One' } - socketClient.send(message) + socketClient.send(JSON.stringify(message)) } function stepOneResponse(socketMessage) { @@ -127,7 +131,7 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets 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 !== DK.NETWORK_CLIENT_USER_PROFILE_HANDLE) { + if (signedMessage.callerProfileHandle !== DK.TEST_NETWORK_CLIENT_USER_PROFILE_HANDLE) { console.log('[ERROR] Web Sockets Client -> stepOneResponse -> The Network Node callerProfileHandle does not match my own userProfileHandle.') return } @@ -155,14 +159,14 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets */ socketClient.onmessage = socketMessage => { stepTwoResponse(socketMessage) } - let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), DK.NETWORK_CLIENT_USER_PROFILE_PRIVATE_KEY) + let signature = web3.eth.accounts.sign(JSON.stringify(signedMessage), DK.TEST_NETWORK_CLIENT_USER_PROFILE_PRIVATE_KEY) let message = { messageType: 'Handshake', signature: JSON.stringify(signature), step: 'Two' } - socketClient.send(message) + socketClient.send(JSON.stringify(message)) } function stepTwoResponse(socketMessage) { @@ -172,6 +176,7 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets console.log('[ERROR] Web Sockets Client -> stepOneResponse -> response.message = ' + response.message) return } + console.log('[INFO] Web Sockets Client -> stepTwoResponse -> response.message = ' + response.message) /* 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 diff --git a/runDesktop.js b/runDesktop.js index 425712d23..96d54c44b 100644 --- a/runDesktop.js +++ b/runDesktop.js @@ -45,8 +45,17 @@ SA.nodeModules = { ws: require('ws') } -DK.NETWORK_CLIENT_USER_PROFILE_HANDLE = "Julian-Molina" // TODO: remove this. -DK.NETWORK_CLIENT_USER_PROFILE_PRIVATE_KEY = "dasdasdjhakdhakhdkalshdkashdka" // TODO: remove this. +/* +We will use this User Profile for Testing Purposes. +{ + "githubUsername": "Test-Network-Client-Profile", + "address": "0xA0dCDA81b42C5EBDc45EC2875C72274B67560246", + "privateKey": "0x5fed4817a87431c8a328d0936561e63f45b6db289adac6125b9306ded644dfe9" +} +*/ + +DK.TEST_NETWORK_CLIENT_USER_PROFILE_HANDLE = "Test-Network-Client-Profile" +DK.TEST_NETWORK_CLIENT_USER_PROFILE_PRIVATE_KEY = "0x5fed4817a87431c8a328d0936561e63f45b6db289adac6125b9306ded644dfe9" DK.app = require('./Desktop/DesktopApp.js').newDesktopApp() DK.app.run() diff --git a/runNetwork.js b/runNetwork.js index e0c5ed174..a0b0b2c33 100644 --- a/runNetwork.js +++ b/runNetwork.js @@ -46,8 +46,16 @@ SA.nodeModules = { ws: require('ws') } -NT.NETWORK_NODE_USER_PROFILE_HANDLE = "Luis-Fernando-Molina" // TODO: remove this. -NT.NETWORK_NODE_USER_PROFILE_PRIVATE_KEY = "blablablablablablablablablablablablablablablablabla" // TODO: remove this. +/* +We will use this User Profile for testing purposes. +{ + "githubUsername": "Test-Network-Node-Profile", + "address": "0xa153469c57A91F5a59Fc6c45A37aD8dbad85e417", + "privateKey": "0xac498ae59407e6b68429a814f64da2339550f93a767578e28c161ff119159271" +} +*/ +NT.NETWORK_NODE_USER_PROFILE_HANDLE = "Test-Network-Node-Profile" +NT.NETWORK_NODE_USER_PROFILE_PRIVATE_KEY = "0xac498ae59407e6b68429a814f64da2339550f93a767578e28c161ff119159271" NT.app = require('./Network/NetwokNode.js').newNetworkNode() NT.app.run()