From 06d0f3bf53f430c5a6cf1e6c849f5749b28964e9 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 09:23:10 +0200 Subject: [PATCH 01/12] Websockets Handshake Procedure --- Client/client.js | 2 +- Client/webSocketsInterface.js | 2 +- Environment.js | 2 +- EnvironmentForDebug.js | 2 +- Network/NetwokNode.js | 3 +- Network/WebSocketsInterface.js | 181 +++++++++++++++++++++++ Projects/Network/NT/Globals/Memory.js | 11 +- Projects/Network/NT/Modules/Bootstrap.js | 5 +- 8 files changed, 196 insertions(+), 12 deletions(-) create mode 100644 Network/WebSocketsInterface.js diff --git a/Client/client.js b/Client/client.js index d44a7aa2b..07990149a 100644 --- a/Client/client.js +++ b/Client/client.js @@ -163,7 +163,7 @@ try { WEB_SOCKETS_INTERFACE = WEB_SOCKETS_INTERFACE.newWebSocketsInterface() WEB_SOCKETS_INTERFACE.initialize() WEB_SOCKETS_INTERFACE.run() - console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.WEB_SOCKETS_INTERFACE_PORT) + console.log('Web Sockets Interface ....................................... Listening at port ' + global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT) HTTP_INTERFACE = HTTP_INTERFACE.newHttpInterface() HTTP_INTERFACE.initialize() diff --git a/Client/webSocketsInterface.js b/Client/webSocketsInterface.js index 84963a977..36dfd2aef 100644 --- a/Client/webSocketsInterface.js +++ b/Client/webSocketsInterface.js @@ -10,7 +10,7 @@ const WEB_SOCKET = require('ws') let socketServer - let port = global.env.WEB_SOCKETS_INTERFACE_PORT + let port = global.env.CLIENT_WEB_SOCKETS_INTERFACE_PORT return thisObject diff --git a/Environment.js b/Environment.js index aed0520ff..76276e22a 100644 --- a/Environment.js +++ b/Environment.js @@ -2,7 +2,7 @@ exports.newEnvironment = function () { let thisObject = { WEB_SERVER_URL: 'localhost', - WEB_SOCKETS_INTERFACE_PORT: 18041, + CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041, HTTP_INTERFACE_PORT: 34248, PATH_TO_TASK_SERVER: './TaskServer', PATH_TO_DATA_STORAGE: './Data-Storage', diff --git a/EnvironmentForDebug.js b/EnvironmentForDebug.js index 3d1094e83..cbb68d289 100644 --- a/EnvironmentForDebug.js +++ b/EnvironmentForDebug.js @@ -2,7 +2,7 @@ exports.newEnvironment = function () { let thisObject = { WEB_SERVER_URL: 'localhost', - WEB_SOCKETS_INTERFACE_PORT: 18041, + CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041, HTTP_INTERFACE_PORT: 34248, PATH_TO_TASK_SERVER: '../TaskServer', PATH_TO_DATA_STORAGE: '../Data-Storage', diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index 73520d046..f712800d4 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -42,7 +42,8 @@ Setting up external dependencies. SA.nodeModules = { fs: require('fs'), nodeFetch: require('node-fetch'), - web3: require('web3') + web3: require('web3'), + ws: require('ws') } start() diff --git a/Network/WebSocketsInterface.js b/Network/WebSocketsInterface.js new file mode 100644 index 000000000..1f80b7d04 --- /dev/null +++ b/Network/WebSocketsInterface.js @@ -0,0 +1,181 @@ +exports.newWebSocketsInterface = function newWebSocketsInterface() { + + let thisObject = { + initialize: initialize, + finalize: finalize, + run: run + } + + let socketServer + let port = global.env.Network_WEB_SOCKETS_INTERFACE_PORT + + return thisObject + + function finalize() { + + } + + function initialize() { + + } + + function run() { + setUpWebSocketServer() + } + + function setUpWebSocketServer() { + try { + socketServer = new SA.nodeModule.ws.Server({ port: port }) + socketServer.on('connection', onConnection) + + function onConnection(socket) { + let caller = {} + socket.on('message', onMenssage) + + + function onMenssage(message) { + try { + let messageHeader = JSON.parse(message) + /* + We will run some validations. + */ + if (messageHeader.messageType === undefined) { + let response = { + result: 'Error', + message: 'messageType Not Provided.' + } + socket.send(JSON.stringify(response)) + return + } + + switch (messageHeader.messageType) { + case "Handshake": { + handShakeProducedure(socket, caller, messageHeader) + break + + } + case "Request": { + break + } + + } + + + + + + + + + + + let origin = messageArray[0] + let nonce = messageArray[1] + let messageToEventServer = messageArray[2] + + if (origin === 'Web Browser') { + try { + JSON.parse(messageToEventServer) + } catch (err) { + console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> Message received from the browser is not a valid JSON. message = ' + message.substring(0, 1000)) + console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> Message received from the browser is not a valid JSON. messageToEventServer = ' + messageToEventServer) + return + } + + let acknowledgeMessage = { + action: 'Acknowledge', + nonce: nonce + } + + socket.send(JSON.stringify(acknowledgeMessage)) + } + + + CL.servers.EVENT_SERVER.onMessage(messageToEventServer, onResponse) + + function onResponse(message) { + socket.send(message) + } + } catch (err) { + console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> Nonce received is less than Last Nonce. err = ' + err.stack) + } + } + } + + + function handShakeProducedure(socket, caller, messageHeader) { + /* + The caller needs to identify itself as either a Network Client or Peer. + */ + if (messageHeader.callerRole === undefined) { + let response = { + result: 'Error', + message: 'callerRole Not Provided.' + } + socket.send(JSON.stringify(response)) + return + } + + if (messageHeader.callerRole !== 'Network Client' && messageHeader.callerRole !== 'Network Peer') { + let response = { + result: 'Error', + message: 'callerRole Not Supported.' + } + socket.send(JSON.stringify(response)) + return + } + + caller.role = messageHeader.callerRole + /* + We will identify the caller by the signature at the message. + */ + if (messageHeader.signature === undefined) { + let response = { + result: 'Error', + message: 'signature Not Provided.' + } + socket.send(JSON.stringify(response)) + return + } + + let web3 = new SA.nodeModules.web3() + let blockchainAccount = web3.eth.accounts.recover(messageHeader.signature) + + if (caller.blockchainAccount === undefined) { + let response = { + result: 'Error', + message: 'Bad signature.' + } + socket.send(JSON.stringify(response)) + return + } + /* + The signature gives us the blockchain account, and the account the user profile. + */ + let userProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount) + + if (userProfile === undefined) { + let response = { + result: 'Error', + message: 'userProfile Not Found.' + } + socket.send(JSON.stringify(response)) + return + } + /* + We will remember the user profile behind this caller. + */ + caller.userProfile = userProfile + + let response = { + result: 'Ok', + message: 'Handshake Successful.' + } + socket.send(JSON.stringify(response)) + } + + } catch (err) { + console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> err.message = ' + err.message.substring(0, 1000)) + } + } +} \ No newline at end of file diff --git a/Projects/Network/NT/Globals/Memory.js b/Projects/Network/NT/Globals/Memory.js index 3248bd2ca..1c5fbb70d 100644 --- a/Projects/Network/NT/Globals/Memory.js +++ b/Projects/Network/NT/Globals/Memory.js @@ -4,13 +4,14 @@ exports.newNetworkGlobalsMemory = function () { */ let thisObject = { maps: { - USER_PROFILES_BY_ID: new Map(), // Here we will store the user profiles by User Profile Id. - USER_PROFILES_BY_HANDLE: new Map(), // Here we will store the user profiles by User Profile Handle. - EVENTS: new Map(), // This is the registry of all events received that prevents processing them more than once. + USER_PROFILES_BY_ID: new Map(), // Here we will store the user profiles by User Profile Id. + USER_PROFILES_BY_HANDLE: new Map(), // Here we will store the user profiles by User Profile Handle. + USER_PROFILES_BY_BLOCHAIN_ACCOUNT: new Map(), // Here we will store the user profiles by Blockchain Account. + EVENTS: new Map(), // This is the registry of all events received that prevents processing them more than once. }, arrays: { - NETWORK_CLIENTS: [], // These are the Network Clients connected to this Network Node ordered by Ranking. - NETWORK_PEERS: [], // These are the Network Peers connected to this Network Node ordered by Ranking. + NETWORK_CLIENTS: [], // These are the Network Clients connected to this Network Node ordered by Ranking. + NETWORK_PEERS: [], // These are the Network Peers connected to this Network Node ordered by Ranking. } } diff --git a/Projects/Network/NT/Modules/Bootstrap.js b/Projects/Network/NT/Modules/Bootstrap.js index b840e3575..c98029769 100644 --- a/Projects/Network/NT/Modules/Bootstrap.js +++ b/Projects/Network/NT/Modules/Bootstrap.js @@ -36,7 +36,7 @@ exports.newBootstrap = function newBootstrap() { let config = JSON.parse(userProfilePlugin.config) let signatureObject = config.signature let web3 = new SA.nodeModules.web3() - let bloackchainAddress = web3.eth.accounts.recover(signatureObject) + let blockchainAccount = web3.eth.accounts.recover(signatureObject) let ranking = 0 // TODO: read the blockchain balance and transactions from the Treasury Account to calculate the profile ranking. let userProfileId = userProfilePlugin.id let userHandle = config.signature.message @@ -45,12 +45,13 @@ exports.newBootstrap = function newBootstrap() { userProfile.initialize( userProfileId, userHandle, - bloackchainAddress, + blockchainAccount, ranking ) NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile) NT.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile) + NT.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile) } } From 6858abf5e260a4a82041db3d37d7b0a2f250f008 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 10:53:34 +0200 Subject: [PATCH 02/12] eventReceived of Client Interface Implemented --- Network/NetwokNode.js | 5 + Network/clientsInterface.js | 87 --------- .../Network/NT/Modules/ClientInterface.js | 166 ++++++++++++++++++ .../Network/NT/Modules/PeerInterface.js | 2 +- .../NT/Modules}/WebSocketsInterface.js | 104 +++++------ Projects/ProjectsSchema.json | 18 ++ 6 files changed, 238 insertions(+), 144 deletions(-) delete mode 100644 Network/clientsInterface.js create mode 100644 Projects/Network/NT/Modules/ClientInterface.js rename Network/peerInterface.js => Projects/Network/NT/Modules/PeerInterface.js (73%) rename {Network => Projects/Network/NT/Modules}/WebSocketsInterface.js (62%) diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index f712800d4..b3eb4577f 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -45,6 +45,11 @@ SA.nodeModules = { web3: require('web3'), ws: require('ws') } +/* +Let's start the Network Interfaces +*/ +NT.webSocketsInterface = NT.projects.network.modules.webSocketsInterface.newNetworkModulesWebSocketsInterface() +NT.webSocketsInterface.initialize() start() diff --git a/Network/clientsInterface.js b/Network/clientsInterface.js deleted file mode 100644 index 2e48e99a4..000000000 --- a/Network/clientsInterface.js +++ /dev/null @@ -1,87 +0,0 @@ -exports.newClientInterface = function newClientInterface() { - /* - This module represents the Interface the Network Node have - with Network Clients connected to it. There are two things - Network Clients can do with this Network Node: - - * Send an Event that happened at the Network Client to the Network. - * Make a Query to the Network Node for info needed at the Network Client. - */ - let thisObject = { - eventReceived: eventReceived, - queryReceived: queryReceived, - initialize: initialize, - finalize: finalize - } - - return thisObject - - function finalize() { - - } - - function initialize() { - - } - - function eventReceived(eventMessage) { - /* - We expect here a JSON string with some or all of the following properties: - - { - "eventId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "eventType": 10, - "emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "emitterBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "targetBBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "emitterPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "targetPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "timestamp": 124234234234, - "botAsset": "BTC", - "botExchange": "Binance", - "botEnabled": true - } - */ - - let eventReceived = JSON.parse(eventMessage) - if (NT.projects.network.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) { - throw ('Event Already Exists.') - } - - let event = NT.projects.network.modules.event.newNetworkModulesEvent() - event.initialize(eventReceived) - NT.projects.network.globals.memory.maps.EVENTS.set(eventReceived.eventId, event) - } - - function queryReceived(queryMessage) { - /* - We expect here a JSON string with some or all of the following properties: - - { - "equeryId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "queryType": 10, - "emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "emitterUserProfileHandle": "Luis-Fernando-Molina", - "targetUserProfileHandle": "Luis-Fernando-Molina", - "emitterBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "targetBBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "emitterPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "targetPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", - "timestamp": 124234234234, - "botAsset": "BTC", - "botExchange": "Binance", - "botEnabled": true, - "initialIndex": 35, - "amountRequested": 50, - "direction": "Past" - } - */ - - let queryReceived = JSON.parse(queryMessage) - let query = NT.projects.network.modules.queriesQuery.newNetworkModulesQuery() - query.initialize(queryReceived) - return query.execute() - } -} \ No newline at end of file diff --git a/Projects/Network/NT/Modules/ClientInterface.js b/Projects/Network/NT/Modules/ClientInterface.js new file mode 100644 index 000000000..f63dce04e --- /dev/null +++ b/Projects/Network/NT/Modules/ClientInterface.js @@ -0,0 +1,166 @@ +exports.newNetworkModulesClientInterface = function newNetworkModulesClientInterface() { + /* + This module represents the Interface the Network Node have + with Network Clients connected to it. There are two things + Network Clients can do with this Network Node: + + * Send an Event that happened at the Network Client to the Network. + * Make a Query to the Network Node for info needed at the Network Client. + */ + let thisObject = { + messageReceived: messageReceived, + initialize: initialize, + finalize: finalize + } + + return thisObject + + function finalize() { + + } + + function initialize() { + + } + + async function messageReceived(message, userProfile) { + let messageHeader + try { + messageHeader = JSON.parse(message) + } catch (err) { + let response = { + result: 'Error', + message: 'Client Interface message Not Coorrect JSON Format.' + } + return response + } + + if (messageHeader.messageType === undefined) { + let response = { + result: 'Error', + message: 'Client Interface messageType Not Provided.' + } + return response + } + + if (messageHeader.messageType !== 'Event' && messageHeader.messageType !== 'Query') { + let response = { + result: 'Error', + message: 'Client Interface messageType Not Supported.' + } + return response + } + + switch (messageHeader.messageType) { + case 'Event': { + return await eventReceived(messageHeader.eventMessage, userProfile) + } + case 'Query': { + return await queryReceived(messageHeader.queryMessage, userProfile) + } + } + } + + async function eventReceived(eventMessage, userProfile) { + /* + We expect here a JSON string with some or all of the following properties: + + { + "eventId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "eventType": 10, + "emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "emitterBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "targetBBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "emitterPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "targetPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "timestamp": 124234234234, + "botAsset": "BTC", + "botExchange": "Binance", + "botEnabled": true + } + */ + + let eventReceived + try { + eventReceived = JSON.parse(eventMessage) + } catch (err) { + let response = { + result: 'Error', + message: 'Client Interface eventMessage Not Coorrect JSON Format.' + } + return response + } + /* + At the Client Interface, events need to be emmitted by the same userProfile that is + connected at the Network Node. + */ + if (eventReceived.emitterUserProfileId !== userProfile.userProfileId) { + let response = { + result: 'Error', + message: 'Client Interface emitterUserProfileId !== userProfileId Connected to Network Node.' + } + return response + } + /* + We will not accept events that have already been processed. + */ + + if (NT.projects.network.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) { + let response = { + result: 'Error', + message: 'Client Interface Event Already Exists.' + } + return response + } + /* + Here we will process the event and change the state of the Social Graph. + */ + try { + let event = NT.projects.network.modules.event.newNetworkModulesEvent() + event.initialize(eventReceived) + NT.projects.network.globals.memory.maps.EVENTS.set(eventReceived.eventId, event) + } catch (err) { + /* + Any exception that happens while trying to change the state of the Social Graph, + will be returned to the caller without doing anything else here. + */ + let response = { + result: 'Error', + message: 'Client Interface ' + err.message + } + return response + } + } + + async function queryReceived(queryMessage) { + /* + We expect here a JSON string with some or all of the following properties: + + { + "equeryId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "queryType": 10, + "emitterUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "targetUserProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "emitterUserProfileHandle": "Luis-Fernando-Molina", + "targetUserProfileHandle": "Luis-Fernando-Molina", + "emitterBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "targetBBotProfileId": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "emitterPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "targetPostHash": "a8de78f0-c3e4-4a2a-b7e8-f659073969db", + "timestamp": 124234234234, + "botAsset": "BTC", + "botExchange": "Binance", + "botEnabled": true, + "initialIndex": 35, + "amountRequested": 50, + "direction": "Past" + } + */ + + let queryReceived = JSON.parse(queryMessage) + let query = NT.projects.network.modules.queriesQuery.newNetworkModulesQuery() + query.initialize(queryReceived) + return query.execute() + } +} \ No newline at end of file diff --git a/Network/peerInterface.js b/Projects/Network/NT/Modules/PeerInterface.js similarity index 73% rename from Network/peerInterface.js rename to Projects/Network/NT/Modules/PeerInterface.js index 423579324..44c4412b0 100644 --- a/Network/peerInterface.js +++ b/Projects/Network/NT/Modules/PeerInterface.js @@ -1,4 +1,4 @@ -exports.newPeerInterface = function newPeerInterface() { +exports.newNetworkModulesPeerInterface = function newNetworkModulesPeerInterface() { let thisObject = { initialize: initialize, diff --git a/Network/WebSocketsInterface.js b/Projects/Network/NT/Modules/WebSocketsInterface.js similarity index 62% rename from Network/WebSocketsInterface.js rename to Projects/Network/NT/Modules/WebSocketsInterface.js index 1f80b7d04..740e6d244 100644 --- a/Network/WebSocketsInterface.js +++ b/Projects/Network/NT/Modules/WebSocketsInterface.js @@ -1,41 +1,51 @@ -exports.newWebSocketsInterface = function newWebSocketsInterface() { +exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSocketsInterface() { let thisObject = { initialize: initialize, - finalize: finalize, - run: run + finalize: finalize } let socketServer - let port = global.env.Network_WEB_SOCKETS_INTERFACE_PORT + let clientInterface + let peerInterface return thisObject function finalize() { - + socketServer = undefined + clientInterface = undefined + peerInterface = undefined } function initialize() { + socketServer = new SA.nodeModule.ws.Server({ port: global.env.Network_WEB_SOCKETS_INTERFACE_PORT }) + clientInterface = NT.projects.network.modules.clientInterface.newNetworkModulesClientInterface() + peerInterface = NT.projects.network.modules.peerInterface.newNetworkModulesPeerInterface() - } - - function run() { setUpWebSocketServer() } function setUpWebSocketServer() { try { - socketServer = new SA.nodeModule.ws.Server({ port: port }) socketServer.on('connection', onConnection) function onConnection(socket) { let caller = {} socket.on('message', onMenssage) - - function onMenssage(message) { + async function onMenssage(message) { try { - let messageHeader = JSON.parse(message) + let messageHeader + try { + messageHeader = JSON.parse(message) + } catch (err) { + let response = { + result: 'Error', + message: 'messageHeader Not Coorrect JSON Format.' + } + socket.send(JSON.stringify(response)) + return + } /* We will run some validations. */ @@ -50,60 +60,42 @@ exports.newWebSocketsInterface = function newWebSocketsInterface() { switch (messageHeader.messageType) { case "Handshake": { - handShakeProducedure(socket, caller, messageHeader) + handshakeProducedure(socket, caller, messageHeader) break - } case "Request": { + + if (caller.userProfile === undefined) { + let response = { + result: 'Error', + message: 'Handshake Not Done Yet.' + } + socket.send(JSON.stringify(response)) + return + } + + switch (caller.role) { + case 'Network Client': { + let response = await clientInterface.messageReceived(messageHeader.payload, caller.userProfile) + socket.send(JSON.stringify(response)) + break + } + case 'Network Peer': { + let response = await peerInterface.messageReceived(messageHeader.payload) + socket.send(JSON.stringify(response)) + break + } + } break } - - } - - - - - - - - - - - let origin = messageArray[0] - let nonce = messageArray[1] - let messageToEventServer = messageArray[2] - - if (origin === 'Web Browser') { - try { - JSON.parse(messageToEventServer) - } catch (err) { - console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> Message received from the browser is not a valid JSON. message = ' + message.substring(0, 1000)) - console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> Message received from the browser is not a valid JSON. messageToEventServer = ' + messageToEventServer) - return - } - - let acknowledgeMessage = { - action: 'Acknowledge', - nonce: nonce - } - - socket.send(JSON.stringify(acknowledgeMessage)) - } - - - CL.servers.EVENT_SERVER.onMessage(messageToEventServer, onResponse) - - function onResponse(message) { - socket.send(message) } } catch (err) { - console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> Nonce received is less than Last Nonce. err = ' + err.stack) + console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> err.stack = ' + err.stack) } } } - - function handShakeProducedure(socket, caller, messageHeader) { + function handshakeProducedure(socket, caller, messageHeader) { /* The caller needs to identify itself as either a Network Client or Peer. */ @@ -175,7 +167,7 @@ exports.newWebSocketsInterface = function newWebSocketsInterface() { } } catch (err) { - console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> err.message = ' + err.message.substring(0, 1000)) + console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> err.stack = ' + err.stack) } } } \ No newline at end of file diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index aaf9a7d65..7b9676298 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -1370,6 +1370,24 @@ "propertyName": "event", "functionName": "newNetworkModulesEvent", "fileName": "Event.js" + }, + { + "name": "Client Interface", + "propertyName": "clientInterface", + "functionName": "newNetworkModulesClientInterface", + "fileName": "ClientInterface.js" + }, + { + "name": "Peer Interface", + "propertyName": "peerInterface", + "functionName": "newNetworkModulesPeerInterface", + "fileName": "PeerInterface.js" + }, + { + "name": "Web Sockets Interface", + "propertyName": "webSocketsInterface", + "functionName": "newNetworkModulesWebSocketsInterface", + "fileName": "WebSocketsInterface.js" } ], "utilities": [ From b264900b87dccd77b71ca3225af1870a00f5f66b Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 11:07:52 +0200 Subject: [PATCH 03/12] Update ClientInterface.js --- .../Network/NT/Modules/ClientInterface.js | 50 +++++++++++++++++-- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/Projects/Network/NT/Modules/ClientInterface.js b/Projects/Network/NT/Modules/ClientInterface.js index f63dce04e..2c04a96f0 100644 --- a/Projects/Network/NT/Modules/ClientInterface.js +++ b/Projects/Network/NT/Modules/ClientInterface.js @@ -120,6 +120,13 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter let event = NT.projects.network.modules.event.newNetworkModulesEvent() event.initialize(eventReceived) NT.projects.network.globals.memory.maps.EVENTS.set(eventReceived.eventId, event) + + let response = { + result: 'Ok', + message: 'Client Interface Event Processed.' + } + return response + } catch (err) { /* Any exception that happens while trying to change the state of the Social Graph, @@ -158,9 +165,44 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter } */ - let queryReceived = JSON.parse(queryMessage) - let query = NT.projects.network.modules.queriesQuery.newNetworkModulesQuery() - query.initialize(queryReceived) - return query.execute() + let queryReceived + try { + queryReceived = JSON.parse(queryMessage) + } catch (err) { + let response = { + result: 'Error', + message: 'Client Interface queryMessage Not Coorrect JSON Format.' + } + return response + } + /* + At the Client Interface, queries need to be emmitted by the same userProfile that is + connected at the Network Node. + */ + if (queryReceived.emitterUserProfileId !== userProfile.userProfileId) { + let response = { + result: 'Error', + message: 'Client Interface emitterUserProfileId !== userProfileId Connected to Network Node.' + } + return response + } + /* + Here we will process the query. This does not change the state of the Social Graph. + */ + try { + let query = NT.projects.network.modules.queriesQuery.newNetworkModulesQuery() + query.initialize(queryReceived) + return query.execute() + + } catch (err) { + /* + Any exception that happens while trying to execute the query. + */ + let response = { + result: 'Error', + message: 'Client Interface ' + err.message + } + return response + } } } \ No newline at end of file From a50a8b7c794458cd3383db5cf456e0d08d2b5252 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 12:23:19 +0200 Subject: [PATCH 04/12] node modules --- package-lock.json => Network/package-lock.json | 0 package.json => Network/package.json | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename package-lock.json => Network/package-lock.json (100%) rename package.json => Network/package.json (100%) diff --git a/package-lock.json b/Network/package-lock.json similarity index 100% rename from package-lock.json rename to Network/package-lock.json diff --git a/package.json b/Network/package.json similarity index 100% rename from package.json rename to Network/package.json From 895c57aa0da05f49e4ee0f9c4aef17b4d251d5e3 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 12:28:49 +0200 Subject: [PATCH 05/12] Node Modules --- Network/package-lock.json | 23 +++++++++++++++-------- Network/package.json | 3 ++- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Network/package-lock.json b/Network/package-lock.json index 890365e86..11e53b3fd 100644 --- a/Network/package-lock.json +++ b/Network/package-lock.json @@ -977,6 +977,18 @@ "servify": "^0.1.12", "ws": "^3.0.0", "xhr-request-promise": "^0.1.2" + }, + "dependencies": { + "ws": { + "version": "3.3.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", + "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "requires": { + "async-limiter": "~1.0.0", + "safe-buffer": "~5.1.0", + "ultron": "~1.1.0" + } + } } }, "ethereum-bloom-filters": { @@ -2945,14 +2957,9 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" }, "ws": { - "version": "3.3.3", - "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", - "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", - "requires": { - "async-limiter": "~1.0.0", - "safe-buffer": "~5.1.0", - "ultron": "~1.1.0" - } + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.1.tgz", + "integrity": "sha512-XkgWpJU3sHU7gX8f13NqTn6KQ85bd1WU7noBHTT8fSohx7OS1TPY8k+cyRPCzFkia7C4mM229yeHr1qK9sM4JQ==" }, "xhr": { "version": "2.6.0", diff --git a/Network/package.json b/Network/package.json index fb7fc1957..98b8d8879 100644 --- a/Network/package.json +++ b/Network/package.json @@ -1,6 +1,7 @@ { "dependencies": { "node-fetch": "^2.6.1", - "web3": "^1.5.2" + "web3": "^1.5.2", + "ws": "^8.2.1" } } From 743885aff59e02dcc170e553e8a468ad0e270200 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 13:26:55 +0200 Subject: [PATCH 06/12] runNetworkScript Debugged --- EnvironmentForDebug.js | 23 ++++--- Network/NetwokNode.js | 69 +++++-------------- .../Network/NT/Modules/WebSocketsInterface.js | 2 +- .../package-lock.json => package-lock.json | 0 Network/package.json => package.json | 0 runNetwork.js | 52 ++++++++++++++ 6 files changed, 82 insertions(+), 64 deletions(-) rename Network/package-lock.json => package-lock.json (100%) rename Network/package.json => package.json (100%) create mode 100644 runNetwork.js diff --git a/EnvironmentForDebug.js b/EnvironmentForDebug.js index cbb68d289..5e88fb9da 100644 --- a/EnvironmentForDebug.js +++ b/EnvironmentForDebug.js @@ -3,19 +3,20 @@ exports.newEnvironment = function () { let thisObject = { WEB_SERVER_URL: 'localhost', CLIENT_WEB_SOCKETS_INTERFACE_PORT: 18041, + NETWORK_WEB_SOCKETS_INTERFACE_PORT: 18042, HTTP_INTERFACE_PORT: 34248, - PATH_TO_TASK_SERVER: '../TaskServer', - PATH_TO_DATA_STORAGE: '../Data-Storage', - PATH_TO_PROJECTS: '../Projects', - PATH_TO_LOG_FILES: '../Log-Files', + PATH_TO_TASK_SERVER: './TaskServer', + PATH_TO_DATA_STORAGE: './Data-Storage', + PATH_TO_PROJECTS: './Projects', + PATH_TO_LOG_FILES: './Log-Files', PATH_TO_PROJECTS_REQUIRED: './Projects', - PATH_TO_PROJECT_SCHEMA: '../Projects/ProjectsSchema.json', - PATH_TO_UI: '../UI', - PATH_TO_DATA_FILES: '../UI/Data-Files/src', - PATH_TO_CLIENT: '../Client/', - PATH_TO_DEFAULT_WORKSPACE: '../Projects/Foundations/Plugins/Workspaces', - PATH_TO_MY_WORKSPACES: '../My-Workspaces', - PATH_TO_FONTS: '../Client/WebServer/Fonts' + PATH_TO_PROJECT_SCHEMA: './Projects/ProjectsSchema.json', + PATH_TO_UI: './UI', + PATH_TO_DATA_FILES: './UI/Data-Files/src', + PATH_TO_CLIENT: './Client/', + PATH_TO_DEFAULT_WORKSPACE: './Projects/Foundations/Plugins/Workspaces', + PATH_TO_MY_WORKSPACES: './My-Workspaces', + PATH_TO_FONTS: './Client/WebServer/Fonts' } return thisObject diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index b3eb4577f..8406c76df 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -1,59 +1,24 @@ -/* -The Superalgos Network offers 3 types of services: +exports.newNetworkNode = function newNetworkNode() { - * Social Graph Service - * Search Index Service - * Private Message Service - -Users can decide which services to run at their node. + let thisObject = { + run: run + } -This module is the starting point of the Network Node. + return thisObject -*/ + function run() { + /* + Let's start the Network Interfaces + */ + NT.webSocketsInterface = NT.projects.network.modules.webSocketsInterface.newNetworkModulesWebSocketsInterface() + NT.webSocketsInterface.initialize() -/* -The NT object is accesible everywhere at the Superalgos Network. -It provides access to all modules built for this Network. -*/ -global.NT = {} -/* -The SA object is accesible everywhere at the Superalgos Network. -It provides access to all modules built for Superalgos in general. -*/ -global.SA = {} -/* Load Environment Variables */ -let ENVIRONMENT = require('../EnvironmentForDebug.js'); -let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() -global.env = ENVIRONMENT_MODULE -/* -First thing is to load the project schema file. -*/ -global.PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECT_SCHEMA) -/* -Setting up the modules that will be available for the Servers Running inside this Client -*/ -let MULTI_PROJECT = require('../MultiProject.js'); -let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject() -MULTI_PROJECT_MODULE.initialize(NT, 'NT') -MULTI_PROJECT_MODULE.initialize(SA, 'SA') -/* -Setting up external dependencies. -*/ -SA.nodeModules = { - fs: require('fs'), - nodeFetch: require('node-fetch'), - web3: require('web3'), - ws: require('ws') -} -/* -Let's start the Network Interfaces -*/ -NT.webSocketsInterface = NT.projects.network.modules.webSocketsInterface.newNetworkModulesWebSocketsInterface() -NT.webSocketsInterface.initialize() + start() -start() + async function start() { + let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() + await socialGraphService.initialize() + } -async function start() { - let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() - await socialGraphService.initialize() + } } diff --git a/Projects/Network/NT/Modules/WebSocketsInterface.js b/Projects/Network/NT/Modules/WebSocketsInterface.js index 740e6d244..912a66740 100644 --- a/Projects/Network/NT/Modules/WebSocketsInterface.js +++ b/Projects/Network/NT/Modules/WebSocketsInterface.js @@ -18,7 +18,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock } function initialize() { - socketServer = new SA.nodeModule.ws.Server({ port: global.env.Network_WEB_SOCKETS_INTERFACE_PORT }) + socketServer = new SA.nodeModules.ws.Server({ port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT }) clientInterface = NT.projects.network.modules.clientInterface.newNetworkModulesClientInterface() peerInterface = NT.projects.network.modules.peerInterface.newNetworkModulesPeerInterface() diff --git a/Network/package-lock.json b/package-lock.json similarity index 100% rename from Network/package-lock.json rename to package-lock.json diff --git a/Network/package.json b/package.json similarity index 100% rename from Network/package.json rename to package.json diff --git a/runNetwork.js b/runNetwork.js new file mode 100644 index 000000000..9aae83d5e --- /dev/null +++ b/runNetwork.js @@ -0,0 +1,52 @@ +/* +The Superalgos Network offers 3 types of services: + + * Social Graph Service + * Search Index Service + * Private Message Service + +Users can decide which services to run at their node.(TODO) + +This module is the starting point of the Network Node. + +*/ + +/* +The NT object is accesible everywhere at the Superalgos Network. +It provides access to all modules built for this Network. +*/ +global.NT = {} +/* +The SA object is accesible everywhere at the Superalgos Network. +It provides access to all modules built for Superalgos in general. +*/ +global.SA = {} +/* Load Environment Variables */ +let ENVIRONMENT = require('./EnvironmentForDebug.js'); +let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() +global.env = ENVIRONMENT_MODULE +/* +First thing is to load the project schema file. +*/ +global.PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECT_SCHEMA) +/* +Setting up the modules that will be available, defined at the Project Schema file. +*/ +let MULTI_PROJECT = require('./MultiProject.js'); +let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject() +MULTI_PROJECT_MODULE.initialize(NT, 'NT') +MULTI_PROJECT_MODULE.initialize(SA, 'SA') +/* +Setting up external dependencies. +*/ +SA.nodeModules = { + fs: require('fs'), + nodeFetch: require('node-fetch'), + web3: require('web3'), + ws: require('ws') +} + +NT.app = require('./Network/NetwokNode.js').newNetworkNode() +NT.app.run() + +console.log('Superalgos Network is Running.') \ No newline at end of file From b262400441a5690ff6545fd1f2d6229cd8632afe Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 13:30:29 +0200 Subject: [PATCH 07/12] Superalgos Network: DeepScan Bugs Fixed --- Projects/Network/NT/Modules/ClientInterface.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Projects/Network/NT/Modules/ClientInterface.js b/Projects/Network/NT/Modules/ClientInterface.js index 2c04a96f0..d96d5d419 100644 --- a/Projects/Network/NT/Modules/ClientInterface.js +++ b/Projects/Network/NT/Modules/ClientInterface.js @@ -140,7 +140,7 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter } } - async function queryReceived(queryMessage) { + async function queryReceived(queryMessage, userProfile) { /* We expect here a JSON string with some or all of the following properties: From b47b9b3dcf57b9e43e7705a0246f4af3ec894667 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 14:42:44 +0200 Subject: [PATCH 08/12] Adding the Social Trading Project --- Desktop/DesktopApp.js | 26 ++ .../.vscode/Superalgos Network.code-workspace | 3 + Network/NetwokNode.js | 2 +- .../Network/NT/Modules/WebSocketsInterface.js | 6 +- Projects/ProjectsSchema.json | 232 +++++++++--------- .../NT/Globals/Memory.js | 2 +- .../NT/Globals/QueryConstants.js | 2 +- .../NT/Modules/Bootstrap.js | 8 +- .../NT/Modules/ClientInterface.js | 10 +- .../NT/Modules/Event.js | 6 +- .../NT/Modules/PeerInterface.js | 2 +- .../NT/Modules/Queries/BotProfileStats.js | 6 +- .../NT/Modules/Queries/Events.js | 18 +- .../NT/Modules/Queries/PostReplies.js | 6 +- .../NT/Modules/Queries/ProfileFollowers.js | 6 +- .../NT/Modules/Queries/ProfileFollowing.js | 6 +- .../NT/Modules/Queries/ProfilePosts.js | 6 +- .../NT/Modules/Queries/UserProfileStats.js | 6 +- .../NT/Modules/Query.js | 16 +- .../NT/Modules/Social-Graph/BotProfile.js | 4 +- .../NT/Modules/Social-Graph/Post.js | 4 +- .../NT/Modules/Social-Graph/UserProfile.js | 6 +- .../NT/Modules/SocialGraph.js | 2 +- .../NT/Utilities/QueriesValidations.js | 14 +- runDesktop.js | 51 ++++ 25 files changed, 270 insertions(+), 180 deletions(-) create mode 100644 Desktop/DesktopApp.js rename Projects/{Network => Social-Trading}/NT/Globals/Memory.js (94%) rename Projects/{Network => Social-Trading}/NT/Globals/QueryConstants.js (80%) rename Projects/{Network => Social-Trading}/NT/Modules/Bootstrap.js (77%) rename Projects/{Network => Social-Trading}/NT/Modules/ClientInterface.js (93%) rename Projects/{Network => Social-Trading}/NT/Modules/Event.js (97%) rename Projects/{Network => Social-Trading}/NT/Modules/PeerInterface.js (71%) rename Projects/{Network => Social-Trading}/NT/Modules/Queries/BotProfileStats.js (78%) rename Projects/{Network => Social-Trading}/NT/Modules/Queries/Events.js (91%) rename Projects/{Network => Social-Trading}/NT/Modules/Queries/PostReplies.js (90%) rename Projects/{Network => Social-Trading}/NT/Modules/Queries/ProfileFollowers.js (86%) rename Projects/{Network => Social-Trading}/NT/Modules/Queries/ProfileFollowing.js (86%) rename Projects/{Network => Social-Trading}/NT/Modules/Queries/ProfilePosts.js (89%) rename Projects/{Network => Social-Trading}/NT/Modules/Queries/UserProfileStats.js (75%) rename Projects/{Network => Social-Trading}/NT/Modules/Query.js (68%) rename Projects/{Network => Social-Trading}/NT/Modules/Social-Graph/BotProfile.js (94%) rename Projects/{Network => Social-Trading}/NT/Modules/Social-Graph/Post.js (94%) rename Projects/{Network => Social-Trading}/NT/Modules/Social-Graph/UserProfile.js (94%) rename Projects/{Network => Social-Trading}/NT/Modules/SocialGraph.js (88%) rename Projects/{Network => Social-Trading}/NT/Utilities/QueriesValidations.js (73%) create mode 100644 runDesktop.js diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js new file mode 100644 index 000000000..6f2bef1ff --- /dev/null +++ b/Desktop/DesktopApp.js @@ -0,0 +1,26 @@ +exports.newDesktopApp = function newDesktopApp() { + + let thisObject = { + run: run + } + + return thisObject + + function run() { + /* + Let's start the Network Interfaces + */ + DK.webSocketsClient = DK.projects.network.modules.webSocketsClient.newDesktopModulesWebSocketsClient() + DK.webSocketsClient.initialize() + + + return + start() + + async function start() { + let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() + await socialGraphService.initialize() + } + + } +} diff --git a/Network/.vscode/Superalgos Network.code-workspace b/Network/.vscode/Superalgos Network.code-workspace index 757812e5e..9970dd1eb 100644 --- a/Network/.vscode/Superalgos Network.code-workspace +++ b/Network/.vscode/Superalgos Network.code-workspace @@ -5,6 +5,9 @@ }, { "path": "C:\\Superalgos\\Projects\\Network" + }, + { + "path": "C:\\Superalgos\\Projects\\Social-Trading" } ], "settings": {} diff --git a/Network/NetwokNode.js b/Network/NetwokNode.js index 8406c76df..af1913a24 100644 --- a/Network/NetwokNode.js +++ b/Network/NetwokNode.js @@ -16,7 +16,7 @@ exports.newNetworkNode = function newNetworkNode() { start() async function start() { - let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph() + let socialGraphService = NT.projects.socialTrading.modules.socialGraph.newSocialGraph() await socialGraphService.initialize() } diff --git a/Projects/Network/NT/Modules/WebSocketsInterface.js b/Projects/Network/NT/Modules/WebSocketsInterface.js index 912a66740..6314b0e95 100644 --- a/Projects/Network/NT/Modules/WebSocketsInterface.js +++ b/Projects/Network/NT/Modules/WebSocketsInterface.js @@ -19,8 +19,8 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock function initialize() { socketServer = new SA.nodeModules.ws.Server({ port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT }) - clientInterface = NT.projects.network.modules.clientInterface.newNetworkModulesClientInterface() - peerInterface = NT.projects.network.modules.peerInterface.newNetworkModulesPeerInterface() + clientInterface = NT.projects.socialTrading.modules.clientInterface.newSocialTradingModulesClientInterface() + peerInterface = NT.projects.socialTrading.modules.peerInterface.newSocialTradingModulesPeerInterface() setUpWebSocketServer() } @@ -144,7 +144,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock /* The signature gives us the blockchain account, and the account the user profile. */ - let userProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount) + let userProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount) if (userProfile === undefined) { let response = { diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 7b9676298..0ba8c9061 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -1272,117 +1272,8 @@ "name": "Network", "propertyName": "network", "NT": { - "globals": [ - { - "name": "Query Constants", - "propertyName": "queryConstants", - "functionName": "newNetworkGlobalsQueryConstants", - "fileName": "QueryConstants.js" - }, - { - "name": "Memory", - "propertyName": "memory", - "functionName": "newNetworkGlobalsMemory", - "fileName": "Memory.js" - } - ], + "globals": [], "modules": [ - { - "name": "Bot Profile Stats", - "propertyName": "queriesBotProfileStats", - "functionName": "newNetworkModulesQueriesBotProfileStats", - "fileName": "Queries/BotProfileStats.js" - }, - { - "name": "User Profile Stats", - "propertyName": "queriesUserProfileStats", - "functionName": "newNetworkModulesQueriesUserProfileStats", - "fileName": "Queries/UserProfileStats.js" - }, - { - "name": "Profile Posts", - "propertyName": "queriesProfilePosts", - "functionName": "newNetworkModulesQueriesProfilePosts", - "fileName": "Queries/ProfilePosts.js" - }, - { - "name": "Profile Followers", - "propertyName": "queriesProfileFollowers", - "functionName": "newNetworkModulesQueriesProfileFollowers", - "fileName": "Queries/ProfileFollowers.js" - }, - { - "name": "Profile Following", - "propertyName": "queriesProfileFollowing", - "functionName": "newNetworkModulesQueriesProfileFollowing", - "fileName": "Queries/ProfileFollowing.js" - }, - { - "name": "Post Replies", - "propertyName": "queriesPostReplies", - "functionName": "newNetworkModulesQueriesPostReplies", - "fileName": "Queries/PostReplies.js" - }, - { - "name": "Events", - "propertyName": "queriesEvents", - "functionName": "newNetworkModulesQueriesEvents", - "fileName": "Queries/Events.js" - }, - { - "name": "User Profile", - "propertyName": "socialGraphUserProfile", - "functionName": "newNetworkModulesSocialGraphUserProfile", - "fileName": "Social-Graph/UserProfile.js" - }, - { - "name": "Bot Profile", - "propertyName": "socialGraphBotProfile", - "functionName": "newNetworkModulesSocialGraphBotProfile", - "fileName": "Social-Graph/BotProfile.js" - }, - { - "name": "Post", - "propertyName": "socialGraphPost", - "functionName": "newNetworkModulesSocialGraphPost", - "fileName": "Social-Graph/Post.js" - }, - { - "name": "Social Graph", - "propertyName": "socialGraph", - "functionName": "newNetworkModulesSocialGraph", - "fileName": "SocialGraph.js" - }, - { - "name": "Bootstrap", - "propertyName": "bootstrap", - "functionName": "newNetworkModulesBootstrap", - "fileName": "Bootstrap.js" - }, - { - "name": "Query", - "propertyName": "Query", - "functionName": "newNetworkModulesQuery", - "fileName": "Query.js" - }, - { - "name": "Event", - "propertyName": "event", - "functionName": "newNetworkModulesEvent", - "fileName": "Event.js" - }, - { - "name": "Client Interface", - "propertyName": "clientInterface", - "functionName": "newNetworkModulesClientInterface", - "fileName": "ClientInterface.js" - }, - { - "name": "Peer Interface", - "propertyName": "peerInterface", - "functionName": "newNetworkModulesPeerInterface", - "fileName": "PeerInterface.js" - }, { "name": "Web Sockets Interface", "propertyName": "webSocketsInterface", @@ -1390,11 +1281,130 @@ "fileName": "WebSocketsInterface.js" } ], + "utilities": [] + } + }, + { + "name": "Social-Trading", + "propertyName": "socialTrading", + "NT": { + "globals": [ + { + "name": "Query Constants", + "propertyName": "queryConstants", + "functionName": "newSocialTradingGlobalsQueryConstants", + "fileName": "QueryConstants.js" + }, + { + "name": "Memory", + "propertyName": "memory", + "functionName": "newSocialTradingGlobalsMemory", + "fileName": "Memory.js" + } + ], + "modules": [ + { + "name": "Bot Profile Stats", + "propertyName": "queriesBotProfileStats", + "functionName": "newSocialTradingModulesQueriesBotProfileStats", + "fileName": "Queries/BotProfileStats.js" + }, + { + "name": "User Profile Stats", + "propertyName": "queriesUserProfileStats", + "functionName": "newSocialTradingModulesQueriesUserProfileStats", + "fileName": "Queries/UserProfileStats.js" + }, + { + "name": "Profile Posts", + "propertyName": "queriesProfilePosts", + "functionName": "newSocialTradingModulesQueriesProfilePosts", + "fileName": "Queries/ProfilePosts.js" + }, + { + "name": "Profile Followers", + "propertyName": "queriesProfileFollowers", + "functionName": "newSocialTradingModulesQueriesProfileFollowers", + "fileName": "Queries/ProfileFollowers.js" + }, + { + "name": "Profile Following", + "propertyName": "queriesProfileFollowing", + "functionName": "newSocialTradingModulesQueriesProfileFollowing", + "fileName": "Queries/ProfileFollowing.js" + }, + { + "name": "Post Replies", + "propertyName": "queriesPostReplies", + "functionName": "newSocialTradingModulesQueriesPostReplies", + "fileName": "Queries/PostReplies.js" + }, + { + "name": "Events", + "propertyName": "queriesEvents", + "functionName": "newSocialTradingModulesQueriesEvents", + "fileName": "Queries/Events.js" + }, + { + "name": "User Profile", + "propertyName": "socialGraphUserProfile", + "functionName": "newSocialTradingModulesSocialGraphUserProfile", + "fileName": "Social-Graph/UserProfile.js" + }, + { + "name": "Bot Profile", + "propertyName": "socialGraphBotProfile", + "functionName": "newSocialTradingModulesSocialGraphBotProfile", + "fileName": "Social-Graph/BotProfile.js" + }, + { + "name": "Post", + "propertyName": "socialGraphPost", + "functionName": "newSocialTradingModulesSocialGraphPost", + "fileName": "Social-Graph/Post.js" + }, + { + "name": "Social Graph", + "propertyName": "socialGraph", + "functionName": "newSocialTradingModulesSocialGraph", + "fileName": "SocialGraph.js" + }, + { + "name": "Bootstrap", + "propertyName": "bootstrap", + "functionName": "newSocialTradingModulesBootstrap", + "fileName": "Bootstrap.js" + }, + { + "name": "Query", + "propertyName": "Query", + "functionName": "newSocialTradingModulesQuery", + "fileName": "Query.js" + }, + { + "name": "Event", + "propertyName": "event", + "functionName": "newSocialTradingModulesEvent", + "fileName": "Event.js" + }, + { + "name": "Client Interface", + "propertyName": "clientInterface", + "functionName": "newSocialTradingModulesClientInterface", + "fileName": "ClientInterface.js" + }, + { + "name": "Peer Interface", + "propertyName": "peerInterface", + "functionName": "newSocialTradingModulesPeerInterface", + "fileName": "PeerInterface.js" + } + ], "utilities": [ { "name": "Queries Validations", "propertyName": "queriesValidations", - "functionName": "newNetworkUtilitiesQueriesValidations", + "functionName": "newSocialTradingUtilitiesQueriesValidations", "fileName": "QueriesValidations.js" } ] diff --git a/Projects/Network/NT/Globals/Memory.js b/Projects/Social-Trading/NT/Globals/Memory.js similarity index 94% rename from Projects/Network/NT/Globals/Memory.js rename to Projects/Social-Trading/NT/Globals/Memory.js index 1c5fbb70d..6a42e762a 100644 --- a/Projects/Network/NT/Globals/Memory.js +++ b/Projects/Social-Trading/NT/Globals/Memory.js @@ -1,4 +1,4 @@ -exports.newNetworkGlobalsMemory = function () { +exports.newSocialTradingGlobalsMemory = function () { /* Here is the Data we are going to keep in memory. */ diff --git a/Projects/Network/NT/Globals/QueryConstants.js b/Projects/Social-Trading/NT/Globals/QueryConstants.js similarity index 80% rename from Projects/Network/NT/Globals/QueryConstants.js rename to Projects/Social-Trading/NT/Globals/QueryConstants.js index 92737b6b4..8f62db770 100644 --- a/Projects/Network/NT/Globals/QueryConstants.js +++ b/Projects/Social-Trading/NT/Globals/QueryConstants.js @@ -1,4 +1,4 @@ -exports.newNetworkGlobalsQueryConstants = function () { +exports.newSocialTradingGlobalsQueryConstants = function () { let thisObject = { INITIAL_INDEX_FIRST: 'First', diff --git a/Projects/Network/NT/Modules/Bootstrap.js b/Projects/Social-Trading/NT/Modules/Bootstrap.js similarity index 77% rename from Projects/Network/NT/Modules/Bootstrap.js rename to Projects/Social-Trading/NT/Modules/Bootstrap.js index c98029769..58ab6bbe1 100644 --- a/Projects/Network/NT/Modules/Bootstrap.js +++ b/Projects/Social-Trading/NT/Modules/Bootstrap.js @@ -41,7 +41,7 @@ exports.newBootstrap = function newBootstrap() { let userProfileId = userProfilePlugin.id let userHandle = config.signature.message - let userProfile = NT.projects.network.modules.socialGraphUserProfile.newNetworkModulesSocialGraphUserProfile() + let userProfile = NT.projects.socialTrading.modules.socialGraphUserProfile.newSocialTradingModulesSocialGraphUserProfile() userProfile.initialize( userProfileId, userHandle, @@ -49,9 +49,9 @@ exports.newBootstrap = function newBootstrap() { ranking ) - NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile) - NT.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile) - NT.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile) + NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile) + NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile) + NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile) } } diff --git a/Projects/Network/NT/Modules/ClientInterface.js b/Projects/Social-Trading/NT/Modules/ClientInterface.js similarity index 93% rename from Projects/Network/NT/Modules/ClientInterface.js rename to Projects/Social-Trading/NT/Modules/ClientInterface.js index d96d5d419..bbfd8b8f1 100644 --- a/Projects/Network/NT/Modules/ClientInterface.js +++ b/Projects/Social-Trading/NT/Modules/ClientInterface.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesClientInterface = function newNetworkModulesClientInterface() { +exports.newSocialTradingModulesClientInterface = function newSocialTradingModulesClientInterface() { /* This module represents the Interface the Network Node have with Network Clients connected to it. There are two things @@ -106,7 +106,7 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter We will not accept events that have already been processed. */ - if (NT.projects.network.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) { + if (NT.projects.socialTrading.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) { let response = { result: 'Error', message: 'Client Interface Event Already Exists.' @@ -117,9 +117,9 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter Here we will process the event and change the state of the Social Graph. */ try { - let event = NT.projects.network.modules.event.newNetworkModulesEvent() + let event = NT.projects.socialTrading.modules.event.newSocialTradingModulesEvent() event.initialize(eventReceived) - NT.projects.network.globals.memory.maps.EVENTS.set(eventReceived.eventId, event) + NT.projects.socialTrading.globals.memory.maps.EVENTS.set(eventReceived.eventId, event) let response = { result: 'Ok', @@ -190,7 +190,7 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter Here we will process the query. This does not change the state of the Social Graph. */ try { - let query = NT.projects.network.modules.queriesQuery.newNetworkModulesQuery() + let query = NT.projects.socialTrading.modules.queriesQuery.newSocialTradingModulesQuery() query.initialize(queryReceived) return query.execute() diff --git a/Projects/Network/NT/Modules/Event.js b/Projects/Social-Trading/NT/Modules/Event.js similarity index 97% rename from Projects/Network/NT/Modules/Event.js rename to Projects/Social-Trading/NT/Modules/Event.js index adbc87424..bd39bcb81 100644 --- a/Projects/Network/NT/Modules/Event.js +++ b/Projects/Social-Trading/NT/Modules/Event.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesEvent = function newNetworkModulesEvent() { +exports.newSocialTradingModulesEvent = function newSocialTradingModulesEvent() { /* An Event is anything that happens system wide that needs to be delivered to relevant entities via @@ -104,7 +104,7 @@ exports.newNetworkModulesEvent = function newNetworkModulesEvent() { if (emitterUserProfileId === undefined) { throw ('Emitter User Profile Id Not Provided.') } - emitterUserProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.emitterUserProfileId) + emitterUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.emitterUserProfileId) if (emitterUserProfile === undefined) { throw ('Emitter User Profile Not Found.') } @@ -112,7 +112,7 @@ exports.newNetworkModulesEvent = function newNetworkModulesEvent() { Validate Target User Profile. */ if (thisObject.targetUserProfileId !== undefined) { - targetUserProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId) + targetUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId) if (targetUserProfile === undefined) { throw ('Target User Profile Not Found.') } diff --git a/Projects/Network/NT/Modules/PeerInterface.js b/Projects/Social-Trading/NT/Modules/PeerInterface.js similarity index 71% rename from Projects/Network/NT/Modules/PeerInterface.js rename to Projects/Social-Trading/NT/Modules/PeerInterface.js index 44c4412b0..6cb730381 100644 --- a/Projects/Network/NT/Modules/PeerInterface.js +++ b/Projects/Social-Trading/NT/Modules/PeerInterface.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesPeerInterface = function newNetworkModulesPeerInterface() { +exports.newSocialTradingModulesPeerInterface = function newSocialTradingModulesPeerInterface() { let thisObject = { initialize: initialize, diff --git a/Projects/Network/NT/Modules/Queries/BotProfileStats.js b/Projects/Social-Trading/NT/Modules/Queries/BotProfileStats.js similarity index 78% rename from Projects/Network/NT/Modules/Queries/BotProfileStats.js rename to Projects/Social-Trading/NT/Modules/Queries/BotProfileStats.js index 9afa338e8..2db10f72b 100644 --- a/Projects/Network/NT/Modules/Queries/BotProfileStats.js +++ b/Projects/Social-Trading/NT/Modules/Queries/BotProfileStats.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQueriesBotProfileStats = function newNetworkModulesQueriesBotProfileStats() { +exports.newSocialTradingModulesQueriesBotProfileStats = function newSocialTradingModulesQueriesBotProfileStats() { let thisObject = { profile: undefined, @@ -19,9 +19,9 @@ exports.newNetworkModulesQueriesBotProfileStats = function newNetworkModulesQuer */ let userProfile if (queryReceived.targetUserProfileId !== undefined) { - userProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId) + userProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId) } else { - userProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle) + userProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle) } if (userProfile === undefined) { diff --git a/Projects/Network/NT/Modules/Queries/Events.js b/Projects/Social-Trading/NT/Modules/Queries/Events.js similarity index 91% rename from Projects/Network/NT/Modules/Queries/Events.js rename to Projects/Social-Trading/NT/Modules/Queries/Events.js index 9d3c2b25b..0565bf027 100644 --- a/Projects/Network/NT/Modules/Queries/Events.js +++ b/Projects/Social-Trading/NT/Modules/Queries/Events.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQueriesEvents = function newNetworkModulesQueriesEvents() { +exports.newSocialTradingModulesQueriesEvents = function newSocialTradingModulesQueriesEvents() { /* This is the query executed to fill the timeline of a certain User or Bot Profile. @@ -29,7 +29,7 @@ exports.newNetworkModulesQueriesEvents = function newNetworkModulesQueriesEvents function execute() { let response = [] switch (thisObject.direction) { - case NT.projects.network.globals.queryConstants.DIRECTION_FUTURE: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let event = NT.memory.arrays.EVENTS[i] if (event === undefined) { break } @@ -37,7 +37,7 @@ exports.newNetworkModulesQueriesEvents = function newNetworkModulesQueriesEvents } break } - case NT.projects.network.globals.queryConstants.DIRECTION_PAST: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let event = NT.memory.arrays.EVENTS[i] if (event === undefined) { break } @@ -59,11 +59,11 @@ exports.newNetworkModulesQueriesEvents = function newNetworkModulesQueriesEvents Any of the above happening, means that indeed it is related. */ - let emitterUserProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(eventReceived.emitterUserProfileId) + let emitterUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(eventReceived.emitterUserProfileId) let emitterBotProfile = emitterUserProfile.bots.get(eventReceived.emitterBotProfileId) let emitterPost = emitterUserProfile.posts.get(eventReceived.emitterPostHash) - let targetUserProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(eventReceived.targetUserProfileId) + let targetUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(eventReceived.targetUserProfileId) let targetBotProfile let targetPost @@ -223,28 +223,28 @@ exports.newNetworkModulesQueriesEvents = function newNetworkModulesQueriesEvents } if (emitterUserProfile !== undefined) { - let query = NT.projects.network.modules.queriesUserProfileStats.newNetworkModulesQueriesUserProfileStats() + let query = NT.projects.socialTrading.modules.queriesUserProfileStats.newSocialTradingModulesQueriesUserProfileStats() query.initialize({ targetUserProfileId: event.emitterUserProfileId }) eventResponse.emitterUserProfile = query.execute() query.finalize() } if (targetUserProfile !== undefined) { - let query = NT.projects.network.modules.queriesUserProfileStats.newNetworkModulesQueriesUserProfileStats() + let query = NT.projects.socialTrading.modules.queriesUserProfileStats.newSocialTradingModulesQueriesUserProfileStats() query.initialize({ targetUserProfileId: event.targetUserProfileId }) eventResponse.targetUserProfile = query.execute() query.finalize() } if (emitterBotProfile !== undefined) { - let query = NT.projects.network.modules.queriesBotProfileStats.newNetworkModulesQueriesBotProfileStats() + let query = NT.projects.socialTrading.modules.queriesBotProfileStats.newSocialTradingModulesQueriesBotProfileStats() query.initialize({ targetUserProfileId: event.emitterUserProfileId, targetBotProfileId: emitterBotProfileId }) eventResponse.emitterBotProfile = query.execute() query.finalize() } if (targetBotProfile !== undefined) { - let query = NT.projects.network.modules.queriesBotProfileStats.newNetworkModulesQueriesBotProfileStats() + let query = NT.projects.socialTrading.modules.queriesBotProfileStats.newSocialTradingModulesQueriesBotProfileStats() query.initialize({ targetUserProfileId: event.targetUserProfileId, targetBotProfileId: targetBotProfileId }) eventResponse.targetBotProfile = query.execute() query.finalize() diff --git a/Projects/Network/NT/Modules/Queries/PostReplies.js b/Projects/Social-Trading/NT/Modules/Queries/PostReplies.js similarity index 90% rename from Projects/Network/NT/Modules/Queries/PostReplies.js rename to Projects/Social-Trading/NT/Modules/Queries/PostReplies.js index 4d7400049..4c0b63ecf 100644 --- a/Projects/Network/NT/Modules/Queries/PostReplies.js +++ b/Projects/Social-Trading/NT/Modules/Queries/PostReplies.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQueriesPostReplies = function newNetworkModulesQueriesPostReplies() { +exports.newSocialTradingModulesQueriesPostReplies = function newSocialTradingModulesQueriesPostReplies() { /* Each Post regardless if it is authored by a User or Bot Profile, can have replies. This query is designed for Network Clients to @@ -39,7 +39,7 @@ exports.newNetworkModulesQueriesPostReplies = function newNetworkModulesQueriesP let array = Array.from(thisObject.post.replies) switch (thisObject.direction) { - case NT.projects.network.globals.queryConstants.DIRECTION_FUTURE: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = array[i] if (post === undefined) { break } @@ -47,7 +47,7 @@ exports.newNetworkModulesQueriesPostReplies = function newNetworkModulesQueriesP } break } - case NT.projects.network.globals.queryConstants.DIRECTION_PAST: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = array[i] if (post === undefined) { break } diff --git a/Projects/Network/NT/Modules/Queries/ProfileFollowers.js b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowers.js similarity index 86% rename from Projects/Network/NT/Modules/Queries/ProfileFollowers.js rename to Projects/Social-Trading/NT/Modules/Queries/ProfileFollowers.js index 929074103..5b500c24c 100644 --- a/Projects/Network/NT/Modules/Queries/ProfileFollowers.js +++ b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowers.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQueriesProfileFollowers = function newNetworkModulesQueriesProfileFollowers() { +exports.newSocialTradingModulesQueriesProfileFollowers = function newSocialTradingModulesQueriesProfileFollowers() { /* This module represents the query that allows a Network Client to know all the User or Bot profiles that are following a certain User or Bot profile. @@ -32,7 +32,7 @@ exports.newNetworkModulesQueriesProfileFollowers = function newNetworkModulesQue let array = Array.from(thisObject.profile.followers) switch (thisObject.direction) { - case NT.projects.network.globals.queryConstants.DIRECTION_FUTURE: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = array[i] if (arrayItem === undefined) { break } @@ -40,7 +40,7 @@ exports.newNetworkModulesQueriesProfileFollowers = function newNetworkModulesQue } break } - case NT.projects.network.globals.queryConstants.DIRECTION_PAST: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = array[i] if (arrayItem === undefined) { break } diff --git a/Projects/Network/NT/Modules/Queries/ProfileFollowing.js b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowing.js similarity index 86% rename from Projects/Network/NT/Modules/Queries/ProfileFollowing.js rename to Projects/Social-Trading/NT/Modules/Queries/ProfileFollowing.js index 19d600d5d..aa21b6193 100644 --- a/Projects/Network/NT/Modules/Queries/ProfileFollowing.js +++ b/Projects/Social-Trading/NT/Modules/Queries/ProfileFollowing.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQueriesProfileFollowing = function newNetworkModulesQueriesProfileFollowing() { +exports.newSocialTradingModulesQueriesProfileFollowing = function newSocialTradingModulesQueriesProfileFollowing() { /* This module represents the query that allows a Network Client to know all the User or Bot profiles that are being followed by a certain User or Bot profile. @@ -32,7 +32,7 @@ exports.newNetworkModulesQueriesProfileFollowing = function newNetworkModulesQue let array = Array.from(thisObject.profile.following) switch (thisObject.direction) { - case NT.projects.network.globals.queryConstants.DIRECTION_FUTURE: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = array[i] if (arrayItem === undefined) { break } @@ -40,7 +40,7 @@ exports.newNetworkModulesQueriesProfileFollowing = function newNetworkModulesQue } break } - case NT.projects.network.globals.queryConstants.DIRECTION_PAST: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = array[i] if (arrayItem === undefined) { break } diff --git a/Projects/Network/NT/Modules/Queries/ProfilePosts.js b/Projects/Social-Trading/NT/Modules/Queries/ProfilePosts.js similarity index 89% rename from Projects/Network/NT/Modules/Queries/ProfilePosts.js rename to Projects/Social-Trading/NT/Modules/Queries/ProfilePosts.js index 07803098c..c14dcd49f 100644 --- a/Projects/Network/NT/Modules/Queries/ProfilePosts.js +++ b/Projects/Social-Trading/NT/Modules/Queries/ProfilePosts.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQueriesUserProfileStats = function newNetworkModulesQueriesUserProfileStats() { +exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradingModulesQueriesUserProfileStats() { /* Each User or Bot Profile can have posts. This query is designed for Network Clients to fetch the posts @@ -35,7 +35,7 @@ exports.newNetworkModulesQueriesUserProfileStats = function newNetworkModulesQue let array = Array.from(thisObject.profile.posts) switch (thisObject.direction) { - case NT.projects.network.globals.queryConstants.DIRECTION_FUTURE: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE: { for (let i = thisObject.initialIndex; i < thisObject.initialIndex + thisObject.amountRequested; i++) { let arrayItem = array[i] if (arrayItem === undefined) { break } @@ -43,7 +43,7 @@ exports.newNetworkModulesQueriesUserProfileStats = function newNetworkModulesQue } break } - case NT.projects.network.globals.queryConstants.DIRECTION_PAST: { + case NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST: { for (let i = thisObject.initialIndex; i > thisObject.initialIndex - thisObject.amountRequested; i--) { let arrayItem = array[i] if (arrayItem === undefined) { break } diff --git a/Projects/Network/NT/Modules/Queries/UserProfileStats.js b/Projects/Social-Trading/NT/Modules/Queries/UserProfileStats.js similarity index 75% rename from Projects/Network/NT/Modules/Queries/UserProfileStats.js rename to Projects/Social-Trading/NT/Modules/Queries/UserProfileStats.js index 0c56e93e4..5825be95f 100644 --- a/Projects/Network/NT/Modules/Queries/UserProfileStats.js +++ b/Projects/Social-Trading/NT/Modules/Queries/UserProfileStats.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQueriesUserProfileStats = function newNetworkModulesQueriesUserProfileStats() { +exports.newSocialTradingModulesQueriesUserProfileStats = function newSocialTradingModulesQueriesUserProfileStats() { let thisObject = { profile: undefined, @@ -18,9 +18,9 @@ exports.newNetworkModulesQueriesUserProfileStats = function newNetworkModulesQue Validate User Profile */ if (queryReceived.targetUserProfileId !== undefined) { - thisObject.profile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId) + thisObject.profile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId) } else { - thisObject.profile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle) + thisObject.profile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_HANDLE.get(queryReceived.targetUserProfileHandle) } if (thisObject.profile === undefined) { diff --git a/Projects/Network/NT/Modules/Query.js b/Projects/Social-Trading/NT/Modules/Query.js similarity index 68% rename from Projects/Network/NT/Modules/Query.js rename to Projects/Social-Trading/NT/Modules/Query.js index aa0022a4c..1a3e9389b 100644 --- a/Projects/Network/NT/Modules/Query.js +++ b/Projects/Social-Trading/NT/Modules/Query.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesQuery = function newNetworkModulesQuery() { +exports.newSocialTradingModulesQuery = function newSocialTradingModulesQuery() { /* A Query is a call from a Network Client to a Network Node with the purpose to get @@ -41,49 +41,49 @@ exports.newNetworkModulesQuery = function newNetworkModulesQuery() { switch (thisObject.queryType) { case QUERY_TYPES.USER_PROFILE_STATS: { - thisObject.query = NT.projects.network.modules.queriesUserProfileStats.newNetworkModulesQueriesUserProfileStats() + thisObject.query = NT.projects.socialTrading.modules.queriesUserProfileStats.newSocialTradingModulesQueriesUserProfileStats() query.initialize(queryReceived) query.finalize() break } case QUERY_TYPES.BOT_PROFILE_STATS: { - thisObject.query = NT.projects.network.modules.queriesBotProfileStats.newNetworkModulesQueriesBotProfileStats() + thisObject.query = NT.projects.socialTrading.modules.queriesBotProfileStats.newSocialTradingModulesQueriesBotProfileStats() query.initialize(queryReceived) query.finalize() break } case QUERY_TYPES.PROFILE_POSTS: { - thisObject.query = NT.projects.network.modules.queriesProfilePosts.newNetworkModulesQueriesProfilePosts() + thisObject.query = NT.projects.socialTrading.modules.queriesProfilePosts.newSocialTradingModulesQueriesProfilePosts() query.initialize(queryReceived) query.finalize() break } case QUERY_TYPES.POST_REPLIES: { - thisObject.query = NT.projects.network.modules.queriesPostReplies.newNetworkModulesQueriesPostReplies() + thisObject.query = NT.projects.socialTrading.modules.queriesPostReplies.newSocialTradingModulesQueriesPostReplies() query.initialize(queryReceived) query.finalize() break } case QUERY_TYPES.PROFILE_FOLLOWERS: { - thisObject.query = NT.projects.network.modules.queriesProfileFollowers.newNetworkModulesQueriesProfileFollowers() + thisObject.query = NT.projects.socialTrading.modules.queriesProfileFollowers.newSocialTradingModulesQueriesProfileFollowers() query.initialize(queryReceived) query.finalize() break } case QUERY_TYPES.PROFILE_FOLLOWING: { - thisObject.query = NT.projects.network.modules.queriesProfileFollowing.newNetworkModulesQueriesProfileFollowing() + thisObject.query = NT.projects.socialTrading.modules.queriesProfileFollowing.newSocialTradingModulesQueriesProfileFollowing() query.initialize(queryReceived) query.finalize() break } case QUERY_TYPES.maps.EVENTS: { - thisObject.query = NT.projects.network.modules.queriesEvents.newNetworkModulesQueriesEvents() + thisObject.query = NT.projects.socialTrading.modules.queriesEvents.newSocialTradingModulesQueriesEvents() query.initialize(queryReceived) query.finalize() break diff --git a/Projects/Network/NT/Modules/Social-Graph/BotProfile.js b/Projects/Social-Trading/NT/Modules/Social-Graph/BotProfile.js similarity index 94% rename from Projects/Network/NT/Modules/Social-Graph/BotProfile.js rename to Projects/Social-Trading/NT/Modules/Social-Graph/BotProfile.js index d860958df..2f1b41b47 100644 --- a/Projects/Network/NT/Modules/Social-Graph/BotProfile.js +++ b/Projects/Social-Trading/NT/Modules/Social-Graph/BotProfile.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesSocialGraphBotProfile = function newNetworkModulesSocialGraphBotProfile() { +exports.newSocialTradingModulesSocialGraphBotProfile = function newSocialTradingModulesSocialGraphBotProfile() { /* Users can have a Profile that can: * follow other bots profiles. @@ -80,7 +80,7 @@ exports.newNetworkModulesSocialGraphBotProfile = function newNetworkModulesSocia if (thisObject.posts.get(emitterPostHash) !== undefined) { throw ('Post Already Exists.') } else { - let post = NT.projects.network.modules.socialGraphPost.newNetworkModulesSocialGraphPost() + let post = NT.projects.socialTrading.modules.socialGraphPost.newSocialTradingModulesSocialGraphPost() post.initialize( emitterUserProfileId, targetUserProfileId, diff --git a/Projects/Network/NT/Modules/Social-Graph/Post.js b/Projects/Social-Trading/NT/Modules/Social-Graph/Post.js similarity index 94% rename from Projects/Network/NT/Modules/Social-Graph/Post.js rename to Projects/Social-Trading/NT/Modules/Social-Graph/Post.js index 36e3541d3..42ffbc346 100644 --- a/Projects/Network/NT/Modules/Social-Graph/Post.js +++ b/Projects/Social-Trading/NT/Modules/Social-Graph/Post.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesSocialGraphPost = function newNetworkModulesSocialGraphPost() { +exports.newSocialTradingModulesSocialGraphPost = function newSocialTradingModulesSocialGraphPost() { /* Posts represent a collection of multimedia content sotored somewhere else and identified by that content hash. Posts might belong to: @@ -97,7 +97,7 @@ exports.newNetworkModulesSocialGraphPost = function newNetworkModulesSocialGraph /* Validate Target User Profile. */ - let targetUserProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId) + let targetUserProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(thisObject.targetUserProfileId) if (targetUserProfile === undefined) { throw ('Target User Profile Not Found.') } diff --git a/Projects/Network/NT/Modules/Social-Graph/UserProfile.js b/Projects/Social-Trading/NT/Modules/Social-Graph/UserProfile.js similarity index 94% rename from Projects/Network/NT/Modules/Social-Graph/UserProfile.js rename to Projects/Social-Trading/NT/Modules/Social-Graph/UserProfile.js index 527b36ef2..a54d0b6b2 100644 --- a/Projects/Network/NT/Modules/Social-Graph/UserProfile.js +++ b/Projects/Social-Trading/NT/Modules/Social-Graph/UserProfile.js @@ -1,4 +1,4 @@ -exports.newNetworkModulesSocialGraphUserProfile = function newNetworkModulesSocialGraphUserProfile() { +exports.newSocialTradingModulesSocialGraphUserProfile = function newSocialTradingModulesSocialGraphUserProfile() { /* Users can have a Profile that can: * follow other user profiles. @@ -84,7 +84,7 @@ exports.newNetworkModulesSocialGraphUserProfile = function newNetworkModulesSoci if (thisObject.posts.get(emitterPostHash) !== undefined) { throw ('Post Already Exists.') } else { - let post = NT.projects.network.modules.socialGraphPost.newNetworkModulesSocialGraphPost() + let post = NT.projects.socialTrading.modules.socialGraphPost.newSocialTradingModulesSocialGraphPost() post.initialize( emitterUserProfileId, targetUserProfileId, @@ -159,7 +159,7 @@ exports.newNetworkModulesSocialGraphUserProfile = function newNetworkModulesSoci if (bot !== undefined) { throw ('Bot Already Exists.') } else { - let bot = NT.projects.network.modules.BOTS.newBot() + let bot = NT.projects.socialTrading.modules.BOTS.newBot() bot.initialize( userProfileId, botProfileId, diff --git a/Projects/Network/NT/Modules/SocialGraph.js b/Projects/Social-Trading/NT/Modules/SocialGraph.js similarity index 88% rename from Projects/Network/NT/Modules/SocialGraph.js rename to Projects/Social-Trading/NT/Modules/SocialGraph.js index 0d475d950..3ac068e92 100644 --- a/Projects/Network/NT/Modules/SocialGraph.js +++ b/Projects/Social-Trading/NT/Modules/SocialGraph.js @@ -21,7 +21,7 @@ exports.newSocialGraph = function newSocialGraph() { } async function initialize() { - let bootstrapProcess = NT.projects.network.modules.bootstrap.newBootstrap() + let bootstrapProcess = NT.projects.socialTrading.modules.bootstrap.newBootstrap() await bootstrapProcess.initialize() } } \ No newline at end of file diff --git a/Projects/Network/NT/Utilities/QueriesValidations.js b/Projects/Social-Trading/NT/Utilities/QueriesValidations.js similarity index 73% rename from Projects/Network/NT/Utilities/QueriesValidations.js rename to Projects/Social-Trading/NT/Utilities/QueriesValidations.js index d98b58e4a..722b54835 100644 --- a/Projects/Network/NT/Utilities/QueriesValidations.js +++ b/Projects/Social-Trading/NT/Utilities/QueriesValidations.js @@ -1,4 +1,4 @@ -exports.newNetworkUtilitiesQueriesValidations = function newNetworkUtilitiesQueriesValidations() { +exports.newSocialTradingUtilitiesQueriesValidations = function newSocialTradingUtilitiesQueriesValidations() { /* This module have a few funcions that are often needed at Queries Modules. */ @@ -15,7 +15,7 @@ exports.newNetworkUtilitiesQueriesValidations = function newNetworkUtilitiesQuer Validate User Profile */ if (queryReceived.targetUserProfileId !== undefined) { - thisObject.profile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId) + thisObject.profile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.get(queryReceived.targetUserProfileId) } if (thisObject.profile === undefined) { @@ -51,11 +51,11 @@ exports.newNetworkUtilitiesQueriesValidations = function newNetworkUtilitiesQuer throw ('Initial Index Undefined.') } - if (queryReceived.initialIndex === NT.projects.network.globals.queryConstants.INITIAL_INDEX_LAST) { + if (queryReceived.initialIndex === NT.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_LAST) { queryReceived.initialIndex = thisObject.profile.posts.length - 1 } - if (queryReceived.initialIndex === NT.projects.network.globals.queryConstants.INITIAL_INDEX_FIRST) { + if (queryReceived.initialIndex === NT.projects.socialTrading.globals.queryConstants.INITIAL_INDEX_FIRST) { queryReceived.initialIndex = 0 } @@ -75,11 +75,11 @@ exports.newNetworkUtilitiesQueriesValidations = function newNetworkUtilitiesQuer throw ('Amount Requested Is Not a Number.') } - if (queryReceived.amountRequested < NT.projects.network.globals.queryConstants.MIN_AMOUNT_REQUESTED) { + if (queryReceived.amountRequested < NT.projects.socialTrading.globals.queryConstants.MIN_AMOUNT_REQUESTED) { throw ('Amount Requested Below Min.') } - if (queryReceived.amountRequested > NT.projects.network.globals.queryConstants.MAX_AMOUNT_REQUESTED) { + if (queryReceived.amountRequested > NT.projects.socialTrading.globals.queryConstants.MAX_AMOUNT_REQUESTED) { throw ('Amount Requested Above Max.') } /* @@ -89,7 +89,7 @@ exports.newNetworkUtilitiesQueriesValidations = function newNetworkUtilitiesQuer throw ('Direction Undefined.') } - if (queryReceived.direction !== NT.projects.network.globals.queryConstants.DIRECTION_FUTURE && queryReceived.direction !== NT.projects.network.globals.queryConstants.DIRECTION_PAST) { + if (queryReceived.direction !== NT.projects.socialTrading.globals.queryConstants.DIRECTION_FUTURE && queryReceived.direction !== NT.projects.socialTrading.globals.queryConstants.DIRECTION_PAST) { throw ('Direction Not Supported.') } diff --git a/runDesktop.js b/runDesktop.js new file mode 100644 index 000000000..250438f83 --- /dev/null +++ b/runDesktop.js @@ -0,0 +1,51 @@ +/* +The Superalgos Desktop is one of the 3 clients of the Superalgos Network: + + * Superalgos Mobile + * Superalgos Desktop + * Superalgos Server + +Users can unse any of these clients for their social trading activities. + +This module is the starting point of the Superalgos Desktop App. + +*/ + +/* +The DK object is accesible everywhere at the Superalgos Desktop App. +It provides access to all modules built for this App. +*/ +global.DK = {} +/* +The SA object is accesible everywhere at the Superalgos Desktop App. +It provides access to all modules built for Superalgos in general. +*/ +global.SA = {} +/* Load Environment Variables */ +let ENVIRONMENT = require('./EnvironmentForDebug.js'); +let ENVIRONMENT_MODULE = ENVIRONMENT.newEnvironment() +global.env = ENVIRONMENT_MODULE +/* +First thing is to load the project schema file. +*/ +global.PROJECTS_SCHEMA = require(global.env.PATH_TO_PROJECT_SCHEMA) +/* +Setting up the modules that will be available, defined at the Project Schema file. +*/ +let MULTI_PROJECT = require('./MultiProject.js'); +let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject() +MULTI_PROJECT_MODULE.initialize(DK, 'DK') +MULTI_PROJECT_MODULE.initialize(SA, 'SA') +/* +Setting up external dependencies. +*/ +SA.nodeModules = { + fs: require('fs'), + web3: require('web3'), + ws: require('ws') +} + +DK.app = require('./Network/DesktopApp.js').newNetworkNode() +DK.app.run() + +console.log('Superalgos Desktop is Running.') \ No newline at end of file From b18b1f234217936be307c63cf7b3cbbdea407326 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 15:48:03 +0200 Subject: [PATCH 09/12] Web Socket Client Implemented --- .../Network/NT/Modules/WebSocietsClient.js | 97 +++++++++++++++++++ .../Network/NT/Modules/WebSocketsInterface.js | 4 +- Projects/ProjectsSchema.json | 6 ++ runDesktop.js | 2 +- 4 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 Projects/Network/NT/Modules/WebSocietsClient.js diff --git a/Projects/Network/NT/Modules/WebSocietsClient.js b/Projects/Network/NT/Modules/WebSocietsClient.js new file mode 100644 index 000000000..996d0d07e --- /dev/null +++ b/Projects/Network/NT/Modules/WebSocietsClient.js @@ -0,0 +1,97 @@ +exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSocketsClient() { + + let thisObject = { + sendMessage: sendMessage, + initialize: initialize, + finalize: finalize + } + + let socketClient + let callbackFunction + + return thisObject + + function finalize() { + socketClient.close() + socketClient = undefined + networkInterface = undefined + peerInterface = undefined + } + + function initialize() { + socketClient = new SA.nodeModules.ws({ host: 'localhost', port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT }) + //networkInterface = SA.projects.socialTrading.modules.networkInterface.newSocialTradingModulesNetworkInterface() + + setUpWebsocketClient() + } + + function setUpWebsocketClient() { + try { + let handshakeDone = false + + socketClient.on('onopen', onConnection) + socketClient.on('onmessage', onMenssage) + socketClient.on('onerror', onError) + + function onConnection(socket) { + /* + Send Handshake Message + */ + socketClient.send('Handshake Message') + console.log('Handshake Message Sent') + } + + async function onMenssage(socketMessage) { + try { + + let message = JSON.parse(socketMessage.data) + /* + Chack if we are waiting for the Handshake response. + */ + if (handshakeDone === false) { + if (message.result === 'Ok') { + handshakeDone = true + return + } + } + + callbackFunction.receiveResponse(message) + callbackFunction = undefined + + } catch (err) { + callbackFunction = undefined + console.log('[ERROR] Web Sockets Client -> setUpWebsocketClient -> err.stack = ' + err.stack) + } + } + + function onError(err) { + console.log('[ERROR] Web Sockets Client -> setUpWebsocketClient -> onError -> err.stack = ' + err.stack) + } + + } catch (err) { + console.log('[ERROR] Web Sockets Client -> setUpWebsocketClient -> err.stack = ' + err.stack) + } + } + + function sendMessage(message, callback) { + if (callbackFunction !== undefined) { + console.log('[ERROR] Web Sockets Client -> sendMessage -> Cannot send more messages while waiting for a response.') + return false + } + + if (socketClient.readyState !== 1) { // 1 means connected and ready. + console.log('[ERROR] Web Sockets Client -> sendMessage -> Cannot send message while connection is closed.') + return false + } + + try { + callbackFunction = callback + socketClient.send(message) + return true + } catch (err) { + callbackFunction = false + console.log('[ERROR] Web Sockets Client -> sendMessage -> err.stack = ' + err.stack) + return false + } + } +} \ No newline at end of file diff --git a/Projects/Network/NT/Modules/WebSocketsInterface.js b/Projects/Network/NT/Modules/WebSocketsInterface.js index 6314b0e95..a1a286d87 100644 --- a/Projects/Network/NT/Modules/WebSocketsInterface.js +++ b/Projects/Network/NT/Modules/WebSocketsInterface.js @@ -90,7 +90,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock } } } catch (err) { - console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> err.stack = ' + err.stack) + console.log('[ERROR] Web Sockets Interface -> setUpWebSocketServer -> err.stack = ' + err.stack) } } } @@ -167,7 +167,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock } } catch (err) { - console.log('[ERROR] Network -> Web Sockets Interface -> run -> setUpWebSocketServer -> err.stack = ' + err.stack) + console.log('[ERROR] Web Sockets Interface -> setUpWebSocketServer -> err.stack = ' + err.stack) } } } \ No newline at end of file diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index 0ba8c9061..fbb9b98df 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -1279,6 +1279,12 @@ "propertyName": "webSocketsInterface", "functionName": "newNetworkModulesWebSocketsInterface", "fileName": "WebSocketsInterface.js" + }, + { + "name": "Web Sockets Client", + "propertyName": "webSocketsClient", + "functionName": "newNetworkModulesWebSocketsClient", + "fileName": "WebSocketsClient.js" } ], "utilities": [] diff --git a/runDesktop.js b/runDesktop.js index 250438f83..96c4c24c5 100644 --- a/runDesktop.js +++ b/runDesktop.js @@ -45,7 +45,7 @@ SA.nodeModules = { ws: require('ws') } -DK.app = require('./Network/DesktopApp.js').newNetworkNode() +DK.app = require('./Desktop/DesktopApp.js').newDesktopApp() DK.app.run() console.log('Superalgos Desktop is Running.') \ No newline at end of file From a4ac062fc0606616132299edfaf630a18fb2e32c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 31 Aug 2021 18:41:58 +0200 Subject: [PATCH 10/12] Superalgos Network: Web Sockets Client and Server working. --- .vscode/Desktop.code-workspace | 10 +++++++ .vscode/Network.code-workspace | 10 +++++++ Desktop/DesktopApp.js | 2 +- .../Modules/WebSocketsClient.js} | 26 +++++++++++-------- Projects/ProjectsSchema.json | 8 +++++- 5 files changed, 43 insertions(+), 13 deletions(-) create mode 100644 .vscode/Desktop.code-workspace create mode 100644 .vscode/Network.code-workspace rename Projects/Network/{NT/Modules/WebSocietsClient.js => SA/Modules/WebSocketsClient.js} (71%) diff --git a/.vscode/Desktop.code-workspace b/.vscode/Desktop.code-workspace new file mode 100644 index 000000000..97e2d4c8f --- /dev/null +++ b/.vscode/Desktop.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "C:\\Superalgos" + } + ], + "settings": { + "search.maintainFileSearchCache": true + } +} \ No newline at end of file diff --git a/.vscode/Network.code-workspace b/.vscode/Network.code-workspace new file mode 100644 index 000000000..97e2d4c8f --- /dev/null +++ b/.vscode/Network.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "C:\\Superalgos" + } + ], + "settings": { + "search.maintainFileSearchCache": true + } +} \ No newline at end of file diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js index 6f2bef1ff..3c225154c 100644 --- a/Desktop/DesktopApp.js +++ b/Desktop/DesktopApp.js @@ -10,7 +10,7 @@ exports.newDesktopApp = function newDesktopApp() { /* Let's start the Network Interfaces */ - DK.webSocketsClient = DK.projects.network.modules.webSocketsClient.newDesktopModulesWebSocketsClient() + DK.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient() DK.webSocketsClient.initialize() diff --git a/Projects/Network/NT/Modules/WebSocietsClient.js b/Projects/Network/SA/Modules/WebSocketsClient.js similarity index 71% rename from Projects/Network/NT/Modules/WebSocietsClient.js rename to Projects/Network/SA/Modules/WebSocketsClient.js index 996d0d07e..01e53f1ed 100644 --- a/Projects/Network/NT/Modules/WebSocietsClient.js +++ b/Projects/Network/SA/Modules/WebSocketsClient.js @@ -19,7 +19,7 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets } function initialize() { - socketClient = new SA.nodeModules.ws({ host: 'localhost', port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT }) + socketClient = new SA.nodeModules.ws('ws://' + 'localhost' + ':' + global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT) //networkInterface = SA.projects.socialTrading.modules.networkInterface.newSocialTradingModulesNetworkInterface() setUpWebsocketClient() @@ -29,11 +29,11 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets try { let handshakeDone = false - socketClient.on('onopen', onConnection) - socketClient.on('onmessage', onMenssage) - socketClient.on('onerror', onError) + socketClient.onopen = () => { onConnection() } + socketClient.onmessage = socketMessage => { onMenssage(socketMessage) } + socketClient.onerror = err => { onError(err) } - function onConnection(socket) { + function onConnection() { /* Send Handshake Message */ @@ -44,28 +44,32 @@ exports.newNetworkModulesWebSocketsClient = function newNetworkModulesWebSockets async function onMenssage(socketMessage) { try { - let message = JSON.parse(socketMessage.data) + let response = JSON.parse(socketMessage.data) /* Chack if we are waiting for the Handshake response. */ if (handshakeDone === false) { - if (message.result === 'Ok') { + if (response.result === 'Ok') { handshakeDone = true return + } else { + console.log('[ERROR] Web Sockets Client -> onMenssage -> handshakeDone -> message.response = ' + response.message) + return } - } - + } + callbackFunction.receiveResponse(message) callbackFunction = undefined } catch (err) { callbackFunction = undefined - console.log('[ERROR] Web Sockets Client -> setUpWebsocketClient -> err.stack = ' + err.stack) + console.log('[ERROR] Web Sockets Client -> err.stack = ' + err.stack) } } function onError(err) { - console.log('[ERROR] Web Sockets Client -> setUpWebsocketClient -> onError -> err.stack = ' + err.stack) + console.log('[ERROR] Web Sockets Client -> onError -> err.message = ' + err.message) + console.log('[ERROR] Web Sockets Client -> onError -> err.stack = ' + err.stack) } } catch (err) { diff --git a/Projects/ProjectsSchema.json b/Projects/ProjectsSchema.json index fbb9b98df..b67c60a29 100644 --- a/Projects/ProjectsSchema.json +++ b/Projects/ProjectsSchema.json @@ -1279,7 +1279,13 @@ "propertyName": "webSocketsInterface", "functionName": "newNetworkModulesWebSocketsInterface", "fileName": "WebSocketsInterface.js" - }, + } + ], + "utilities": [] + }, + "SA": { + "globals": [], + "modules": [ { "name": "Web Sockets Client", "propertyName": "webSocketsClient", From 1cb72cfbc255fb8adb531664c2d8600ee6c3ee75 Mon Sep 17 00:00:00 2001 From: Raphl2502 Date: Tue, 31 Aug 2021 22:20:28 +0200 Subject: [PATCH 11/12] Submission of thomas profile (Raphl2502) --- .../Plugins/User-Profiles/Raplh2502.json | 791 ++++++++++++++---- 1 file changed, 622 insertions(+), 169 deletions(-) diff --git a/Projects/Governance/Plugins/User-Profiles/Raplh2502.json b/Projects/Governance/Plugins/User-Profiles/Raplh2502.json index e8ff6a5de..7c3c10360 100644 --- a/Projects/Governance/Plugins/User-Profiles/Raplh2502.json +++ b/Projects/Governance/Plugins/User-Profiles/Raplh2502.json @@ -1,7 +1,7 @@ { "type": "User Profile", "name": "Raplh2502", - "config": "{\n \"signature\": {\n \"message\": \"Raplh2502\",\n \"messageHash\": \"0x002241abadf010338ef270d56138327b257a020ba556107b978f7e4a4f78e10f\",\n \"v\": \"0x1b\",\n \"r\": \"0xa45e37a0d602e45300e319a1ee714dcee22fdd44774b638a6086fe66fd5d25b1\",\n \"s\": \"0x36c0c11cbc382a559ae30d7d53940586b60b5a28e39a3240af33a58129accc25\",\n \"signature\": \"0xa45e37a0d602e45300e319a1ee714dcee22fdd44774b638a6086fe66fd5d25b136c0c11cbc382a559ae30d7d53940586b60b5a28e39a3240af33a58129accc251b\"\n },\n \"codeName\": \"Raplh2502\"\n}", + "config": "{\"signature\":{\"message\":\"Raplh2502\",\"messageHash\":\"0x002241abadf010338ef270d56138327b257a020ba556107b978f7e4a4f78e10f\",\"v\":\"0x1b\",\"r\":\"0xa45e37a0d602e45300e319a1ee714dcee22fdd44774b638a6086fe66fd5d25b1\",\"s\":\"0x36c0c11cbc382a559ae30d7d53940586b60b5a28e39a3240af33a58129accc25\",\"signature\":\"0xa45e37a0d602e45300e319a1ee714dcee22fdd44774b638a6086fe66fd5d25b136c0c11cbc382a559ae30d7d53940586b60b5a28e39a3240af33a58129accc251b\"},\"codeName\":\"Raplh2502\"}", "project": "Governance", "tokenPowerSwitch": { "type": "Token Power Switch", @@ -14,26 +14,26 @@ "name": "New Community Building Programs", "config": "{}", "project": "Governance", - "supportProgram": { - "type": "Support Program", - "name": "New Support Program", + "referralProgram": { + "type": "Referral Program", + "name": "New Referral Program", "config": "{}", "project": "Governance", - "userSupporters": [ + "userReferrers": [ { - "type": "User Supporter", + "type": "User Referrer", "name": "Julian-Molina", "config": "{}", "project": "Governance", - "id": "8654e417-6ac3-44da-89de-b348fba4aed4", + "id": "6cbb2eb6-53ee-4d1a-a7bb-f941553ce10e", "savedPayload": { "position": { - "x": 35941.4493554574, - "y": 23003.65789426258 + "x": 30040.192378864664, + "y": 24100 }, "targetPosition": { - "x": 36241.4493554574, - "y": 23003.65789426258 + "x": 30190.192378864664, + "y": 23840.192378864667 }, "floatingObject": { "isPinned": false, @@ -54,85 +54,9 @@ "referenceParentCombinedNodePath": [ [ "Julian-Molina", - "User Profile" - ] - ] - } - }, - { - "type": "User Supporter", - "name": "harrellbm", - "config": "{}", - "project": "Governance", - "id": "47ec59fb-4a1e-4e8d-a2df-5796ad4f8a7d", - "savedPayload": { - "position": { - "x": 36091.4493554574, - "y": 22743.850273127246 - }, - "targetPosition": { - "x": 36241.4493554574, - "y": 23003.65789426258 - }, - "floatingObject": { - "isPinned": false, - "isFrozen": false, - "isCollapsed": false, - "angleToParent": 1, - "distanceToParent": 3, - "arrangementStyle": 0 - }, - "uiObject": { - "isRunning": false - }, - "referenceParent": { - "type": "User Profile", - "name": "harrellbm", - "id": "107d3e44-1685-4540-8316-3bc6591298e9" - }, - "referenceParentCombinedNodePath": [ - [ - "harrellbm", - "User Profile" - ] - ] - } - }, - { - "type": "User Supporter", - "name": "Luis-Fernando-Molina", - "config": "{}", - "project": "Governance", - "id": "9d61971c-d916-454a-97a0-9d7a68747175", - "savedPayload": { - "position": { - "x": 36391.4493554574, - "y": 22743.850273127246 - }, - "targetPosition": { - "x": 36241.4493554574, - "y": 23003.65789426258 - }, - "floatingObject": { - "isPinned": false, - "isFrozen": false, - "isCollapsed": false, - "angleToParent": 1, - "distanceToParent": 3, - "arrangementStyle": 0 - }, - "uiObject": { - "isRunning": false - }, - "referenceParent": { - "type": "User Profile", - "name": "Luis-Fernando-Molina", - "id": "148911b3-b2f3-44fb-8cb4-017991789132" - }, - "referenceParentCombinedNodePath": [ - [ - "Luis-Fernando-Molina", - "User Profile" + "User Profile", + "Governance", + "1fd95e41-4b22-48d5-be3a-904c37afcb11" ] ] } @@ -142,15 +66,15 @@ "type": "Tokens Awarded", "name": "New Tokens Awarded", "project": "Governance", - "id": "8ac68836-fdb6-4549-83bb-4d9d253cec6e", + "id": "e80cafb6-7090-4eaa-b674-f9b5b5b8a42e", "savedPayload": { "position": { - "x": 36541.4493554574, - "y": 23003.65789426258 + "x": 29930.38475772933, + "y": 23690.192378864667 }, "targetPosition": { - "x": 36241.4493554574, - "y": 23003.65789426258 + "x": 30190.192378864664, + "y": 23840.192378864667 }, "floatingObject": { "isPinned": false, @@ -169,15 +93,15 @@ "type": "Tokens Bonus", "name": "New Tokens Bonus", "project": "Governance", - "id": "de5c95e6-ff42-41a9-a253-7cd0115234ac", + "id": "8ef66cc7-be91-48e0-b065-bda219234215", "savedPayload": { "position": { - "x": 36391.4493554574, - "y": 23263.46551539791 + "x": 30340.192378864664, + "y": 23580.384757729335 }, "targetPosition": { - "x": 36241.4493554574, - "y": 23003.65789426258 + "x": 30190.192378864664, + "y": 23840.192378864667 }, "floatingObject": { "isPinned": false, @@ -192,15 +116,15 @@ } } }, - "id": "6b249e23-8de3-48e9-9f11-14f8c57dd8d5", + "id": "83a049e3-5222-4656-a6de-2ba670ae06dd", "savedPayload": { "position": { - "x": 36241.4493554574, - "y": 23003.65789426258 + "x": 30190.192378864664, + "y": 23840.192378864667 }, "targetPosition": { - "x": 36091.4493554574, - "y": 23263.46551539791 + "x": 30449.999999999996, + "y": 23990.192378864667 }, "floatingObject": { "isPinned": false, @@ -215,15 +139,544 @@ } } }, - "id": "61dfffc2-6a9a-450a-abe6-78c19ef34f73", + "supportProgram": { + "type": "Support Program", + "name": "New Support Program", + "config": "{}", + "project": "Governance", + "userSupporters": [ + { + "type": "User Supporter", + "name": "Julian-Molina", + "config": "{}", + "project": "Governance", + "id": "98b2403d-8b67-4589-99e0-e324cfed7540", + "savedPayload": { + "position": { + "x": 42707.936362707216, + "y": 24108.655750652073 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "Julian-Molina", + "id": "1fd95e41-4b22-48d5-be3a-904c37afcb11" + }, + "referenceParentCombinedNodePath": [ + [ + "Julian-Molina", + "User Profile", + "Governance", + "1fd95e41-4b22-48d5-be3a-904c37afcb11" + ] + ] + } + }, + { + "type": "User Supporter", + "name": "harrellbm", + "config": "{}", + "project": "Governance", + "id": "e456cb6d-3935-4d0c-b744-053a5658aeb4", + "savedPayload": { + "position": { + "x": 42688.555719779855, + "y": 23924.261250484007 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "harrellbm", + "id": "3af73d3b-7c0e-4de7-a1e1-a72238081740" + }, + "referenceParentCombinedNodePath": [ + [ + "harrellbm", + "User Profile", + "Governance", + "3af73d3b-7c0e-4de7-a1e1-a72238081740" + ] + ] + } + }, + { + "type": "User Supporter", + "name": "Luis-Fernando-Molina", + "config": "{}", + "project": "Governance", + "id": "162e169b-5db5-4977-bf65-e0b2e643c7eb", + "savedPayload": { + "position": { + "x": 42781.26081809234, + "y": 23763.691310086117 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "Luis-Fernando-Molina", + "id": "a8de78f0-c3e4-4a2a-b7e8-f659073969db" + }, + "referenceParentCombinedNodePath": [ + [ + "Luis-Fernando-Molina", + "User Profile", + "Governance", + "a8de78f0-c3e4-4a2a-b7e8-f659073969db" + ] + ] + } + }, + { + "type": "User Supporter", + "name": "ssplatt", + "config": "{}", + "project": "Governance", + "id": "43c5b4ff-44e0-4f9f-803b-5e054b92df1a", + "savedPayload": { + "position": { + "x": 42950.6414610197, + "y": 23688.278189118853 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "ssplatt", + "id": "56600855-7a91-49e8-8a58-2fa28d07efd1" + }, + "referenceParentCombinedNodePath": [ + [ + "ssplatt", + "User Profile" + ] + ] + } + }, + { + "type": "User Supporter", + "name": "9808us", + "config": "{}", + "project": "Governance", + "id": "7b4f9489-a596-4298-9b94-b66d2d4658bd", + "savedPayload": { + "position": { + "x": 43132, + "y": 23726.827136594 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "9808us", + "id": "280f0baf-bc13-497c-b255-618c1a146442" + }, + "referenceParentCombinedNodePath": [ + [ + "9808us", + "User Profile" + ] + ] + } + }, + { + "type": "User Supporter", + "name": "Smidy13", + "config": "{}", + "project": "Governance", + "id": "fd7c0cb5-00d4-4a39-9a43-90353d47aed1", + "savedPayload": { + "position": { + "x": 43256.063637292784, + "y": 23864.613764806596 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "Smidy13", + "id": "4b5eca40-4d97-454d-91f3-8627a98ef682" + }, + "referenceParentCombinedNodePath": [ + [ + "Smidy13", + "User Profile" + ] + ] + } + }, + { + "type": "User Supporter", + "name": "cozed-gh", + "config": "{}", + "project": "Governance", + "id": "96b71bb0-b795-4925-a1b6-f6a2ebc37aca", + "savedPayload": { + "position": { + "x": 43275.444280220145, + "y": 24049.008264974662 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "cozed-gh", + "id": "07f0b13a-a50f-4488-8a2c-a3f8f08e889d" + }, + "referenceParentCombinedNodePath": [ + [ + "cozed-gh", + "User Profile" + ] + ] + } + } + ], + "tokensAwarded": { + "type": "Tokens Awarded", + "name": "New Tokens Awarded", + "project": "Governance", + "id": "c551ba14-52b5-49a1-9359-e2573d39ae3d", + "savedPayload": { + "position": { + "x": 43182.73918190766, + "y": 24209.578205372552 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "tokensBonus": { + "type": "Tokens Bonus", + "name": "New Tokens Bonus", + "project": "Governance", + "id": "f8c43611-cecd-4606-914a-45554b4b933a", + "savedPayload": { + "position": { + "x": 43013.3585389803, + "y": 24284.991326339816 + }, + "targetPosition": { + "x": 42982, + "y": 23986.634757729335 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "id": "cbf9752e-13db-443c-8f42-0001df229ac9", + "savedPayload": { + "position": { + "x": 30599.999999999996, + "y": 23730.384757729335 + }, + "targetPosition": { + "x": 30449.999999999996, + "y": 23990.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": true, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "mentorshipProgram": { + "type": "Mentorship Program", + "name": "New Mentorship Program", + "config": "{}", + "project": "Governance", + "userMentors": [ + { + "type": "User Mentor", + "name": "Luis-Fernando-Molina", + "config": "{}", + "project": "Governance", + "id": "6e659c1f-e68f-4d74-a878-052f3a5082a6", + "savedPayload": { + "position": { + "x": 30772.181128380656, + "y": 23846.748098644526 + }, + "targetPosition": { + "x": 30709.80762113533, + "y": 24140.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "Luis-Fernando-Molina", + "id": "a8de78f0-c3e4-4a2a-b7e8-f659073969db" + }, + "referenceParentCombinedNodePath": [ + [ + "Luis-Fernando-Molina", + "User Profile", + "Governance", + "a8de78f0-c3e4-4a2a-b7e8-f659073969db" + ] + ] + } + }, + { + "type": "User Mentor", + "name": "PLuv", + "config": "{}", + "project": "Governance", + "id": "130fc498-de5e-4607-bb18-dd8ba5b4bf18", + "savedPayload": { + "position": { + "x": 31008.16418974581, + "y": 24108.83383988437 + }, + "targetPosition": { + "x": 30709.80762113533, + "y": 24140.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "User Profile", + "name": "PLuv", + "id": "142f5de2-3762-4f55-a839-22eac5c03c8f" + }, + "referenceParentCombinedNodePath": [ + [ + "PLuv", + "User Profile", + "Governance", + "142f5de2-3762-4f55-a839-22eac5c03c8f" + ] + ] + } + } + ], + "tokensAwarded": { + "type": "Tokens Awarded", + "name": "New Tokens Awarded", + "project": "Governance", + "id": "a335874e-f035-4301-aa67-157a9b831f6a", + "savedPayload": { + "position": { + "x": 30831.828614058068, + "y": 24414.256016157447 + }, + "targetPosition": { + "x": 30709.80762113533, + "y": 24140.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "tokensBonus": { + "type": "Tokens Bonus", + "name": "New Tokens Bonus", + "project": "Governance", + "id": "3fdc564c-e5d9-4b87-9f28-1440d68b0723", + "savedPayload": { + "position": { + "x": 30486.86417349211, + "y": 24340.931560772326 + }, + "targetPosition": { + "x": 30709.80762113533, + "y": 24140.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "id": "86586fb4-2a3b-49d6-bdd5-36975fa1a0a9", + "savedPayload": { + "position": { + "x": 30709.80762113533, + "y": 24140.192378864667 + }, + "targetPosition": { + "x": 30449.999999999996, + "y": 23990.192378864667 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": true, + "angleToParent": 1, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + }, + "id": "a32cc538-068f-49fd-a426-100a29f90339", "savedPayload": { "position": { - "x": 36091.4493554574, - "y": 23263.46551539791 + "x": 30449.999999999996, + "y": 23990.192378864667 }, "targetPosition": { - "x": 35941.4493554574, - "y": 23523.273136533244 + "x": 30299.999999999996, + "y": 24250 }, "floatingObject": { "isPinned": false, @@ -262,15 +715,15 @@ "name": "", "config": "{}", "project": "Governance", - "id": "2dd37827-1cc1-40aa-b89a-917ccfe24d9b", + "id": "28aedac0-26d8-4278-9b75-3c10cf83e2a0", "savedPayload": { "position": { - "x": 36501.25697659273, - "y": 23592.88837880391 + "x": 35060.4883090863, + "y": 10904.798575428878 }, "targetPosition": { - "x": 36501.25697659273, - "y": 23892.88837880391 + "x": 35060.4883090863, + "y": 11204.798575428878 }, "floatingObject": { "isPinned": false, @@ -314,18 +767,18 @@ }, { "type": "Feature Contribution Claim", - "name": "User Defined Variables and Code New Features", + "name": "", "config": "{}", "project": "Governance", - "id": "67e36fdc-9a1d-42c7-a62a-e99c605c5d33", + "id": "664ff3bf-0cad-467a-868f-d16a9ab4cc54", "savedPayload": { "position": { - "x": 36761.064597728066, - "y": 24042.88837880391 + "x": 35320.29593022163, + "y": 11354.798575428878 }, "targetPosition": { - "x": 36501.25697659273, - "y": 23892.88837880391 + "x": 35060.4883090863, + "y": 11204.798575428878 }, "floatingObject": { "isPinned": false, @@ -368,15 +821,15 @@ } } ], - "id": "a0af8811-9dc2-4a9a-a28f-358738a6994f", + "id": "f0f53e80-19a7-4364-b484-61b6242e7b8b", "savedPayload": { "position": { - "x": 36501.25697659273, - "y": 23892.88837880391 + "x": 35060.4883090863, + "y": 11204.798575428878 }, "targetPosition": { - "x": 36241.4493554574, - "y": 24042.88837880391 + "x": 34800.68068795097, + "y": 11354.798575428878 }, "floatingObject": { "isPinned": false, @@ -402,18 +855,18 @@ "positionContributionClaims": [ { "type": "Position Contribution Claim", - "name": "Moderator Community Management", + "name": "", "config": "{}", "project": "Governance", - "id": "74cbbf75-2a2c-4081-9415-ba423848f2db", + "id": "ea777ab1-3cbf-4a71-935c-b0edd69f88ce", "savedPayload": { "position": { - "x": 36541.4493554574, - "y": 24562.503621074575 + "x": 35100.68068795097, + "y": 11874.413817699544 }, "targetPosition": { - "x": 36391.4493554574, - "y": 24302.695999939242 + "x": 34950.68068795097, + "y": 11614.606196564211 }, "floatingObject": { "isPinned": false, @@ -452,15 +905,15 @@ } } ], - "id": "e880f8a6-8e53-43dd-8b11-4210ca18c9ab", + "id": "2277d694-8325-4db1-997b-4d2972e7c232", "savedPayload": { "position": { - "x": 36391.4493554574, - "y": 24302.695999939242 + "x": 34950.68068795097, + "y": 11614.606196564211 }, "targetPosition": { - "x": 36241.4493554574, - "y": 24042.88837880391 + "x": 34800.68068795097, + "y": 11354.798575428878 }, "floatingObject": { "isPinned": false, @@ -499,15 +952,15 @@ "type": "Tokens Awarded", "name": "New Tokens Awarded", "project": "Governance", - "id": "f7c63ab2-c803-4886-b043-6c6297981f85", + "id": "fdf321ca-029e-45c5-8178-6d28f5031ceb", "savedPayload": { "position": { - "x": 35981.64173432207, - "y": 24192.88837880391 + "x": 34540.873066815635, + "y": 11504.798575428878 }, "targetPosition": { - "x": 36241.4493554574, - "y": 24042.88837880391 + "x": 34800.68068795097, + "y": 11354.798575428878 }, "floatingObject": { "isPinned": false, @@ -522,20 +975,20 @@ } } }, - "id": "bd26adac-cf78-4aec-888f-a8718a657469", + "id": "f719f049-9b08-4343-8b4d-6bf4e48638b1", "savedPayload": { "position": { - "x": 36241.4493554574, - "y": 24042.88837880391 + "x": 30599.999999999996, + "y": 24769.615242270665 }, "targetPosition": { - "x": 36091.4493554574, - "y": 23783.080757668577 + "x": 30449.999999999996, + "y": 24509.807621135333 }, "floatingObject": { "isPinned": false, "isFrozen": false, - "isCollapsed": false, + "isCollapsed": true, "angleToParent": 1, "distanceToParent": 3, "arrangementStyle": 0 @@ -545,15 +998,15 @@ } } }, - "id": "22eacf7e-c02b-4853-a529-7789aeadb64e", + "id": "d317ab89-cb64-426b-931c-48755502da5d", "savedPayload": { "position": { - "x": 36091.4493554574, - "y": 23783.080757668577 + "x": 30449.999999999996, + "y": 24509.807621135333 }, "targetPosition": { - "x": 35941.4493554574, - "y": 23523.273136533244 + "x": 30299.999999999996, + "y": 24250 }, "floatingObject": { "isPinned": false, @@ -568,15 +1021,15 @@ } } }, - "id": "13f0fedf-2d0a-4b80-a191-05236a8138a6", + "id": "c67fa458-eb61-44c4-8f83-8cd5f8d1dbf9", "savedPayload": { "position": { - "x": 35941.4493554574, - "y": 23523.273136533244 + "x": 30299.999999999996, + "y": 24250 }, "targetPosition": { - "x": 35641.4493554574, - "y": 23523.273136533244 + "x": 29999.999999999996, + "y": 24250 }, "floatingObject": { "isPinned": false, @@ -595,15 +1048,15 @@ "type": "Tokens Mined", "name": "New Tokens Mined", "project": "Governance", - "id": "b4c844ba-f1c1-44e8-96f6-96fbd6a8cbfd", + "id": "ea95efe5-2255-480b-8a3d-8c3e2fc62202", "savedPayload": { "position": { - "x": 35341.4493554574, - "y": 23523.273136533244 + "x": 29699.999999999996, + "y": 24250 }, "targetPosition": { - "x": 35641.4493554574, - "y": 23523.273136533244 + "x": 29999.999999999996, + "y": 24250 }, "floatingObject": { "isPinned": false, @@ -618,20 +1071,20 @@ } } }, - "id": "59a87d1a-0457-4a49-a11b-216716e5c889", + "id": "c538f02f-9a2c-47e2-bf92-f6e97ede4031", "savedPayload": { "position": { - "x": 35641.4493554574, - "y": 23523.273136533244 + "x": 29999.999999999996, + "y": 24250 }, "targetPosition": { - "x": 35641.4493554574, - "y": 23523.273136533244 + "x": 29999.999999999996, + "y": 24250 }, "floatingObject": { "isPinned": true, "isFrozen": false, - "isCollapsed": false, + "isCollapsed": true, "angleToParent": 1, "distanceToParent": 3, "arrangementStyle": 0 From 0ef9969e555d2e080936669d7d38aedbf16c94db Mon Sep 17 00:00:00 2001 From: Philip Love Date: Wed, 1 Sep 2021 00:58:51 -0400 Subject: [PATCH 12/12] Modify setup.js: In event WinOS error installing TF-modules provides user with detailed instructions on how to get their WinOS/nodejs dependencies installed correctly to facilitate installation of tfjs-node --- .../Plugins/User-Profiles/PLuv.json | 764 +++++++++++++----- setup.js | 33 +- 2 files changed, 586 insertions(+), 211 deletions(-) diff --git a/Projects/Governance/Plugins/User-Profiles/PLuv.json b/Projects/Governance/Plugins/User-Profiles/PLuv.json index 430ae1b92..d97b9e7ec 100644 --- a/Projects/Governance/Plugins/User-Profiles/PLuv.json +++ b/Projects/Governance/Plugins/User-Profiles/PLuv.json @@ -127,12 +127,12 @@ "id": "6d16ca2f-a4e7-4c12-bc3c-98754ac90e08", "savedPayload": { "position": { - "x": 19408.46583462777, - "y": 16805.50679562789 + "x": 16873.961568354185, + "y": 17964.683045111455 }, "targetPosition": { - "x": 19501.17093294025, - "y": 17090.823750516436 + "x": 16966.666666666668, + "y": 18250 }, "floatingObject": { "isPinned": false, @@ -150,7 +150,7 @@ "communityBuildingPrograms": { "type": "Community Building Programs", "name": "New Community Building Programs", - "config": "{\n \"percentage\": 3\n}", + "config": "{\n \"percentage\": 1\n}", "project": "Governance", "referralProgram": { "type": "Referral Program", @@ -900,12 +900,12 @@ "id": "7d10759e-f52d-418a-9a0c-2cf0bbb3e309", "savedPayload": { "position": { - "x": 19743.876031252734, - "y": 16914.488174828693 + "x": 17209.37176497915, + "y": 18073.664424312257 }, "targetPosition": { - "x": 19501.17093294025, - "y": 17090.823750516436 + "x": 16966.666666666668, + "y": 18250 }, "floatingObject": { "isPinned": false, @@ -934,7 +934,7 @@ { "type": "Votes Switch", "name": "Other People's Stuff", - "config": "{\n \"percentage\": 3\n}", + "config": "{\n \"percentage\": 1\n}", "project": "Governance", "votesSwitch": [], "claimVotesSwitch": [ @@ -1348,12 +1348,12 @@ "id": "9df9510a-691c-4f05-bea4-214ea218263e", "savedPayload": { "position": { - "x": 19077.09315829752, - "y": 16072.912037378894 + "x": 19483.09315829752, + "y": 16331.912037378896 }, "targetPosition": { - "x": 19748.395437671104, - "y": 16143.468750084561 + "x": 20154.395437671104, + "y": 16402.46875008456 }, "floatingObject": { "isPinned": false, @@ -1384,12 +1384,12 @@ "id": "6292f3d5-fcaa-4249-97e1-094fc6cd3faa", "savedPayload": { "position": { - "x": 18338.202519733757, - "y": 15851.574899334562 + "x": 18772.266615918157, + "y": 16207.532982488976 }, "targetPosition": { - "x": 19323.604173712465, - "y": 15618.895226101107 + "x": 19729.604173712465, + "y": 15877.895226101105 }, "floatingObject": { "isPinned": false, @@ -1467,12 +1467,12 @@ "id": "c182f0a8-e833-4455-9018-8008781e5bfe", "savedPayload": { "position": { - "x": 18334.832034458916, - "y": 15400.98261371725 + "x": 18717.258382366617, + "y": 15860.224664583357 }, "targetPosition": { - "x": 19323.604173712465, - "y": 15618.895226101107 + "x": 19729.604173712465, + "y": 15877.895226101105 }, "floatingObject": { "isPinned": false, @@ -1550,12 +1550,12 @@ "id": "2b483422-88aa-40d1-8901-8e23293425fa", "savedPayload": { "position": { - "x": 18527.29999785772, - "y": 14993.550593505366 + "x": 18784.353991884047, + "y": 15515.047677186489 }, "targetPosition": { - "x": 19323.604173712465, - "y": 15618.895226101107 + "x": 19729.604173712465, + "y": 15877.895226101105 }, "floatingObject": { "isPinned": false, @@ -1633,12 +1633,12 @@ "id": "b21f9f40-267d-4148-9735-829647ccc5ae", "savedPayload": { "position": { - "x": 18877.485769314382, - "y": 14709.97574712769 + "x": 18965.46072373691, + "y": 15213.635459248217 }, "targetPosition": { - "x": 19323.604173712465, - "y": 15618.895226101107 + "x": 19729.604173712465, + "y": 15877.895226101105 }, "floatingObject": { "isPinned": false, @@ -1716,12 +1716,12 @@ "id": "efe425a4-b02d-4cf1-942f-21de1c782f25", "savedPayload": { "position": { - "x": 19316.03076204526, - "y": 14606.42355072657 + "x": 19238.73443321305, + "y": 14992.342772622467 }, "targetPosition": { - "x": 19323.604173712465, - "y": 15618.895226101107 + "x": 19729.604173712465, + "y": 15877.895226101105 }, "floatingObject": { "isPinned": false, @@ -1805,12 +1805,12 @@ "id": "13bb8738-b245-467f-850b-2b46cad1f16e", "savedPayload": { "position": { - "x": 19756.075761838627, - "y": 14703.403786783601 + "x": 19571.21427785923, + "y": 14877.860781248528 }, "targetPosition": { - "x": 19323.604173712465, - "y": 15618.895226101107 + "x": 19729.604173712465, + "y": 15877.895226101105 }, "floatingObject": { "isPinned": false, @@ -1867,18 +1867,184 @@ ] ] } + }, + { + "type": "Asset Claim Vote", + "name": "Smidy13 ", + "config": "{}", + "project": "Governance", + "id": "f39a2c29-1935-4233-95d8-b343b314d6e4", + "savedPayload": { + "position": { + "x": 19922.798281531217, + "y": 14883.997702860346 + }, + "targetPosition": { + "x": 19729.604173712465, + "y": 15877.895226101105 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 4, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "Asset Contribution Claim", + "name": "", + "id": "f1add2dd-8cbc-40c0-a189-922b3d729e06" + }, + "referenceParentCombinedNodePath": [ + [ + "Smidy13", + "User Profile", + "Governance", + "4b5eca40-4d97-454d-91f3-8627a98ef682" + ], + [ + "New Token Power Switch", + "Token Power Switch", + "Governance", + "7fb54153-47b4-48dc-b2e0-99b52eda5949" + ], + [ + "New Votes And Claims Programs", + "Votes And Claims Programs", + "Governance", + "7b4da8e8-6c7e-43eb-bfab-22c4b57ad286" + ], + [ + "New Claims Program", + "Claims Program", + "Governance", + "121a7d91-bb40-466f-88a4-b354fd22e1d6" + ], + [ + "New Asset Claims Folder", + "Asset Claims Folder", + "Governance", + "22f676a5-1868-473c-b3e5-a70faf6d35b5" + ], + [ + "Foundations", + "Asset Claims Folder", + "Governance", + "c987460d-37a3-4e72-8a56-04dd07944313" + ], + [ + "Bug Fixes", + "Asset Claims Folder", + "Governance", + "7682f51b-38f8-4cfa-becd-48113ce3c6cd" + ], + [ + "", + "Asset Contribution Claim", + "Governance", + "f1add2dd-8cbc-40c0-a189-922b3d729e06" + ] + ] + } + }, + { + "type": "Asset Claim Vote", + "name": "Smidy13 ", + "config": "{}", + "project": "Governance", + "id": "69077036-299f-4d31-8ef5-0f544b052158", + "savedPayload": { + "position": { + "x": 20251.080224558897, + "y": 15010.013334140216 + }, + "targetPosition": { + "x": 19729.604173712465, + "y": 15877.895226101105 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 4, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "Asset Contribution Claim", + "name": "", + "id": "2f1021db-f803-44a2-a40b-6593f590589d" + }, + "referenceParentCombinedNodePath": [ + [ + "Smidy13", + "User Profile", + "Governance", + "4b5eca40-4d97-454d-91f3-8627a98ef682" + ], + [ + "New Token Power Switch", + "Token Power Switch", + "Governance", + "7fb54153-47b4-48dc-b2e0-99b52eda5949" + ], + [ + "New Votes And Claims Programs", + "Votes And Claims Programs", + "Governance", + "7b4da8e8-6c7e-43eb-bfab-22c4b57ad286" + ], + [ + "New Claims Program", + "Claims Program", + "Governance", + "121a7d91-bb40-466f-88a4-b354fd22e1d6" + ], + [ + "New Asset Claims Folder", + "Asset Claims Folder", + "Governance", + "22f676a5-1868-473c-b3e5-a70faf6d35b5" + ], + [ + "Foundations", + "Asset Claims Folder", + "Governance", + "c987460d-37a3-4e72-8a56-04dd07944313" + ], + [ + "Bug Fixes", + "Asset Claims Folder", + "Governance", + "7682f51b-38f8-4cfa-becd-48113ce3c6cd" + ], + [ + "", + "Asset Contribution Claim", + "Governance", + "2f1021db-f803-44a2-a40b-6593f590589d" + ] + ] + } } ], "featureClaimVotes": [], "id": "c1768c6f-680c-4ac7-b255-741cc0c8a8a9", "savedPayload": { "position": { - "x": 19323.604173712465, - "y": 15618.895226101107 + "x": 19729.604173712465, + "y": 15877.895226101105 }, "targetPosition": { - "x": 19748.395437671104, - "y": 16143.468750084561 + "x": 20154.395437671104, + "y": 16402.46875008456 }, "floatingObject": { "isPinned": false, @@ -1910,12 +2076,12 @@ "id": "a6c1ced3-2da8-48a3-ad5c-ee63064df8f4", "savedPayload": { "position": { - "x": 19601.666682280975, - "y": 15648.120773420254 + "x": 20007.666682280975, + "y": 15907.120773420254 }, "targetPosition": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "floatingObject": { "isPinned": false, @@ -1987,18 +2153,18 @@ "id": "708dc168-d47c-4105-81b5-261ab635a1d5", "savedPayload": { "position": { - "x": 19848.17769769592, - "y": 15194.103962142464 + "x": 20749.525674360226, + "y": 15306.375206752335 }, "targetPosition": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "floatingObject": { "isPinned": false, "isFrozen": false, "isCollapsed": false, - "angleToParent": 1, + "angleToParent": 2, "distanceToParent": 3, "arrangementStyle": 0 }, @@ -2064,18 +2230,18 @@ "id": "e02a4ea0-0971-4f40-8442-ff66cea39bfe", "savedPayload": { "position": { - "x": 20343.525674360226, - "y": 15047.375206752335 + "x": 21001.051124829795, + "y": 15384.475935079094 }, "targetPosition": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "floatingObject": { "isPinned": false, "isFrozen": false, "isCollapsed": false, - "angleToParent": 1, + "angleToParent": 2, "distanceToParent": 3, "arrangementStyle": 0 }, @@ -2141,18 +2307,18 @@ "id": "21af8982-6406-4eab-b2c0-9711c45b68f9", "savedPayload": { "position": { - "x": 20797.542485638012, - "y": 15293.886222167279 + "x": 21203.542485638012, + "y": 15552.886222167279 }, "targetPosition": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "floatingObject": { "isPinned": false, "isFrozen": false, "isCollapsed": false, - "angleToParent": 1, + "angleToParent": 2, "distanceToParent": 3, "arrangementStyle": 0 }, @@ -2218,18 +2384,18 @@ "id": "06b3fe21-0af3-4098-aa29-92d6b761d82c", "savedPayload": { "position": { - "x": 20944.271241028142, - "y": 15789.234198831586 + "x": 21326.17228269059, + "y": 15785.967128450773 }, "targetPosition": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "floatingObject": { "isPinned": false, "isFrozen": false, "isCollapsed": false, - "angleToParent": 1, + "angleToParent": 2, "distanceToParent": 3, "arrangementStyle": 0 }, @@ -2289,18 +2455,18 @@ "id": "5a5c2895-4761-48ac-a1ef-4b51ab40ee05", "savedPayload": { "position": { - "x": 20697.760225613198, - "y": 16243.251010109376 + "x": 21350.271241028142, + "y": 16048.234198831586 }, "targetPosition": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "floatingObject": { "isPinned": false, "isFrozen": false, "isCollapsed": false, - "angleToParent": 1, + "angleToParent": 2, "distanceToParent": 3, "arrangementStyle": 0 }, @@ -2372,18 +2538,18 @@ "id": "38b6d567-4641-40ec-893e-9f76cca8ebd8", "savedPayload": { "position": { - "x": 20202.41224894889, - "y": 16389.979765499505 + "x": 21272.170512701385, + "y": 16299.759649301155 }, "targetPosition": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "floatingObject": { "isPinned": false, "isFrozen": false, "isCollapsed": false, - "angleToParent": 1, + "angleToParent": 2, "distanceToParent": 3, "arrangementStyle": 0 }, @@ -2451,12 +2617,12 @@ "id": "efbc2c39-9c26-41af-bca5-0222fb9f6a4c", "savedPayload": { "position": { - "x": 20272.96896165456, - "y": 15718.677486125918 + "x": 20678.96896165456, + "y": 15977.67748612592 }, "targetPosition": { - "x": 19748.395437671104, - "y": 16143.468750084561 + "x": 20154.395437671104, + "y": 16402.46875008456 }, "floatingObject": { "isPinned": false, @@ -2478,12 +2644,12 @@ "id": "38ad8b59-129e-460e-bbfe-cc6e328992b7", "savedPayload": { "position": { - "x": 19748.395437671104, - "y": 16143.468750084561 + "x": 20154.395437671104, + "y": 16402.46875008456 }, "targetPosition": { - "x": 20031.589613643533, - "y": 16493.1844327402 + "x": 20437.589613643533, + "y": 16752.1844327402 }, "floatingObject": { "isPinned": false, @@ -10338,12 +10504,12 @@ "id": "6eba9686-b5d4-44cb-bde9-002082ed733a", "savedPayload": { "position": { - "x": 20381.30529629917, - "y": 16209.990256767771 + "x": 20787.30529629917, + "y": 16468.99025676777 }, "targetPosition": { - "x": 20031.589613643533, - "y": 16493.1844327402 + "x": 20437.589613643533, + "y": 16752.1844327402 }, "floatingObject": { "isPinned": false, @@ -10364,12 +10530,12 @@ "id": "e071b504-73cb-4d66-bc92-90a5c48e17b0", "savedPayload": { "position": { - "x": 20437.589613643533, - "y": 16752.1844327402 + "x": 17903.08534736995, + "y": 17911.360682223763 }, "targetPosition": { - "x": 20276.32403634815, - "y": 17172.29562466394 + "x": 17741.819770074566, + "y": 18331.471874147504 }, "floatingObject": { "isPinned": false, @@ -10409,17 +10575,17 @@ { "type": "Feature Claim Vote", "name": "PLuv Tensor Flow Integration New Features", - "config": "{}", + "config": "{\n \"percentage\": 50\n}", "project": "Governance", "id": "7e7385b4-9f96-4da7-9066-e010e1023905", "savedPayload": { "position": { - "x": 21410.05612022855, - "y": 15994.640145511272 + "x": 18654.88074998019, + "y": 17100.83795018773 }, "targetPosition": { - "x": 21363.018311758107, - "y": 16442.174998426995 + "x": 18725.276259248294, + "y": 17545.297703455544 }, "floatingObject": { "isPinned": false, @@ -10480,17 +10646,17 @@ { "type": "Feature Claim Vote", "name": "PLuv User Defined Variables and Code New Features", - "config": "{\n}", + "config": "{}", "project": "Governance", "id": "72086cca-208e-4864-8a21-51fadac28c98", "savedPayload": { "position": { - "x": 21774.11376769728, - "y": 16259.143509042886 + "x": 19074.991941903932, + "y": 17262.103527483116 }, "targetPosition": { - "x": 21363.018311758107, - "y": 16442.174998426995 + "x": 18725.276259248294, + "y": 17545.297703455544 }, "floatingObject": { "isPinned": false, @@ -10552,12 +10718,12 @@ "id": "33000f65-87b3-45c2-aaec-067b12404b88", "savedPayload": { "position": { - "x": 21363.018311758107, - "y": 16442.174998426995 + "x": 18725.276259248294, + "y": 17545.297703455544 }, "targetPosition": { - "x": 21098.514948226493, - "y": 16806.23264589572 + "x": 18564.01068195291, + "y": 17965.408895379285 }, "floatingObject": { "isPinned": false, @@ -10624,12 +10790,12 @@ "id": "40a03471-49ab-4b22-8d38-47676d0469d5", "savedPayload": { "position": { - "x": 21993.58465405794, - "y": 16900.308262836606 + "x": 19386.201593831254, + "y": 17599.345916611066 }, "targetPosition": { - "x": 21546.049801142217, - "y": 16853.270454366164 + "x": 18975.106137892082, + "y": 17782.377405995176 }, "floatingObject": { "isPinned": false, @@ -10693,12 +10859,195 @@ "id": "8b21bb4d-41f5-4876-9e62-4665f1429cf4", "savedPayload": { "position": { - "x": 21546.049801142217, - "y": 16853.270454366164 + "x": 18975.106137892082, + "y": 17782.377405995176 }, "targetPosition": { - "x": 21098.514948226493, - "y": 16806.23264589572 + "x": 18564.01068195291, + "y": 17965.408895379285 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + } + } + } + ], + "weightVotesSwitch": [ + { + "type": "Weight Votes Switch", + "name": "New Weight Votes Switch", + "config": "{\n \"percentage\": 0\n}", + "project": "Governance", + "weightVotesSwitch": [], + "poolWeightVotes": [ + { + "type": "Pool Weight Vote", + "name": "Project Positions, Assets, Features Pool Class", + "config": "{}", + "project": "Governance", + "id": "dd6428c8-059a-47e2-adc7-e1de10ec621c", + "savedPayload": { + "position": { + "x": 19395.217329815823, + "y": 17943.64298329056 + }, + "targetPosition": { + "x": 18984.12187387665, + "y": 18126.67447267467 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "Pool Class", + "name": "Project Positions, Assets, Features", + "id": "b27df32a-70f3-470b-b8bb-471c156b0c30" + }, + "referenceParentCombinedNodePath": [ + [ + "Superalgos", + "Pools", + "Governance", + "6f0aed87-db13-4818-bfe6-68abc463ebec" + ], + [ + "Project Positions, Assets, Features", + "Pool Class", + "Governance", + "b27df32a-70f3-470b-b8bb-471c156b0c30" + ] + ] + } + }, + { + "type": "Pool Weight Vote", + "name": "Features Pool Class", + "config": "{\n \"percentage\": 25\n}", + "project": "Governance", + "id": "81da8791-9e3f-4c6b-897e-40d82f1a0551", + "savedPayload": { + "position": { + "x": 19404.233065800392, + "y": 18287.940049970053 + }, + "targetPosition": { + "x": 18984.12187387665, + "y": 18126.67447267467 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "Pool Class", + "name": "Features", + "id": "a1bc781c-242d-464f-8e1a-ee34b76e139c" + }, + "referenceParentCombinedNodePath": [ + [ + "Superalgos", + "Pools", + "Governance", + "6f0aed87-db13-4818-bfe6-68abc463ebec" + ], + [ + "Project Positions, Assets, Features", + "Pool Class", + "Governance", + "b27df32a-70f3-470b-b8bb-471c156b0c30" + ], + [ + "Features", + "Pool Class", + "Governance", + "a1bc781c-242d-464f-8e1a-ee34b76e139c" + ] + ] + } + }, + { + "type": "Pool Weight Vote", + "name": "Exchanges Pool Class", + "config": "{\n}", + "project": "Governance", + "id": "7839eb51-c4a5-4e0e-a2fd-fd01d0f9b2f0", + "savedPayload": { + "position": { + "x": 19167.15336326076, + "y": 18537.76992861384 + }, + "targetPosition": { + "x": 18984.12187387665, + "y": 18126.67447267467 + }, + "floatingObject": { + "isPinned": false, + "isFrozen": false, + "isCollapsed": false, + "angleToParent": 2, + "distanceToParent": 3, + "arrangementStyle": 0 + }, + "uiObject": { + "isRunning": false + }, + "referenceParent": { + "type": "Pool Class", + "name": "Exchanges", + "id": "b6d7a4fe-8990-47a2-a7ce-f5fd90384b53" + }, + "referenceParentCombinedNodePath": [ + [ + "Superalgos", + "Pools", + "Governance", + "6f0aed87-db13-4818-bfe6-68abc463ebec" + ], + [ + "Exchanges", + "Pool Class", + "Governance", + "b6d7a4fe-8990-47a2-a7ce-f5fd90384b53" + ] + ] + } + } + ], + "assetWeightVotes": [], + "featureWeightVotes": [], + "positionWeightVotes": [], + "id": "e182eed3-badb-4d47-8cd4-5bac2399d501", + "savedPayload": { + "position": { + "x": 18984.12187387665, + "y": 18126.67447267467 + }, + "targetPosition": { + "x": 18564.01068195291, + "y": 17965.408895379285 }, "floatingObject": { "isPinned": false, @@ -10714,17 +11063,16 @@ } } ], - "weightVotesSwitch": [], "userProfileVotesSwitch": [], "id": "9a70336d-9543-401a-bd60-a6c2fa8c08fb", "savedPayload": { "position": { - "x": 21098.514948226493, - "y": 16806.23264589572 + "x": 18564.01068195291, + "y": 17965.408895379285 }, "targetPosition": { - "x": 20687.41949228732, - "y": 16989.26413527983 + "x": 18152.915226013738, + "y": 18148.440384763395 }, "floatingObject": { "isPinned": false, @@ -10746,12 +11094,12 @@ "id": "268bce42-91b0-4de4-bb36-7055b75db2b9", "savedPayload": { "position": { - "x": 20687.41949228732, - "y": 16989.26413527983 + "x": 18152.915226013738, + "y": 18148.440384763395 }, "targetPosition": { - "x": 20276.32403634815, - "y": 17172.29562466394 + "x": 17741.819770074566, + "y": 18331.471874147504 }, "floatingObject": { "isPinned": false, @@ -10774,12 +11122,12 @@ "id": "6091d138-b20d-4a19-b8cb-24142377abb7", "savedPayload": { "position": { - "x": 20486.379632310018, - "y": 17252.928413311634 + "x": 17951.875366036435, + "y": 18412.1046627952 }, "targetPosition": { - "x": 20276.32403634815, - "y": 17172.29562466394 + "x": 17741.819770074566, + "y": 18331.471874147504 }, "floatingObject": { "isPinned": false, @@ -10797,12 +11145,12 @@ "id": "6106dc15-c8c2-49fb-9db3-c494711ef844", "savedPayload": { "position": { - "x": 20276.32403634815, - "y": 17172.29562466394 + "x": 17741.819770074566, + "y": 18331.471874147504 }, "targetPosition": { - "x": 19865.228580408977, - "y": 17355.32711404805 + "x": 17330.724314135394, + "y": 18514.503363531614 }, "floatingObject": { "isPinned": false, @@ -10820,7 +11168,7 @@ "claimsProgram": { "type": "Claims Program", "name": "New Claims Program", - "config": "{\n \"percentage\": 50\n}", + "config": "{\n \"percentage\": 51\n}", "project": "Governance", "assetClaimsFolders": [ { @@ -10838,12 +11186,12 @@ "id": "e0f84f5a-a3fc-4fc2-8c82-9116b20ea4d5", "savedPayload": { "position": { - "x": 20640.38168381688, - "y": 17436.798988195555 + "x": 18105.877417543295, + "y": 18595.97523767912 }, "targetPosition": { - "x": 20229.286227877707, - "y": 17619.830477579664 + "x": 17694.781961604123, + "y": 18779.006727063228 }, "floatingObject": { "isPinned": false, @@ -10885,12 +11233,12 @@ "id": "dc382aa3-fb73-4770-817d-2d69da57fd26", "savedPayload": { "position": { - "x": 20229.286227877707, - "y": 17619.830477579664 + "x": 17694.781961604123, + "y": 18779.006727063228 }, "targetPosition": { - "x": 19818.190771938534, - "y": 17802.861966963774 + "x": 17283.68650566495, + "y": 18962.038216447338 }, "floatingObject": { "isPinned": false, @@ -10920,12 +11268,12 @@ "id": "7a943c21-0e4d-4ca2-ad65-2cee16923774", "savedPayload": { "position": { - "x": 20626.708172675073, - "y": 17996.969821227285 + "x": 18092.20390640149, + "y": 19156.14607071085 }, "targetPosition": { - "x": 20182.24841940726, - "y": 18067.365330495388 + "x": 17647.744153133677, + "y": 19226.54157997895 }, "floatingObject": { "isPinned": false, @@ -10979,12 +11327,12 @@ "id": "e44cbbd2-9ee2-46e9-aad1-747ac5670bea", "savedPayload": { "position": { - "x": 20546.306066875986, - "y": 18331.868694027 + "x": 18011.801800602403, + "y": 19491.044943510566 }, "targetPosition": { - "x": 20182.24841940726, - "y": 18067.365330495388 + "x": 17647.744153133677, + "y": 19226.54157997895 }, "floatingObject": { "isPinned": false, @@ -11038,12 +11386,12 @@ "id": "d90040a0-f341-4ccc-b04f-5e86b12de4a6", "savedPayload": { "position": { - "x": 20252.643928675363, - "y": 18511.8250837632 + "x": 17718.13966240178, + "y": 19671.001333246764 }, "targetPosition": { - "x": 20182.24841940726, - "y": 18067.365330495388 + "x": 17647.744153133677, + "y": 19226.54157997895 }, "floatingObject": { "isPinned": false, @@ -11093,12 +11441,12 @@ "id": "d64547b8-fa87-4ea3-a53a-90d55b325d14", "savedPayload": { "position": { - "x": 20182.24841940726, - "y": 18067.365330495388 + "x": 17647.744153133677, + "y": 19226.54157997895 }, "targetPosition": { - "x": 19818.190771938534, - "y": 17802.861966963774 + "x": 17283.68650566495, + "y": 18962.038216447338 }, "floatingObject": { "isPinned": false, @@ -11152,17 +11500,17 @@ { "type": "Feature Contribution Claim", "name": "Tensor Flow Integration New Features", - "config": "{}", + "config": "{\n \"percentage\": 50\n}", "project": "Governance", "id": "b79c3adb-f641-42a9-bba9-312afb225a7b", "savedPayload": { "position": { - "x": 20135.210610936818, - "y": 18514.90018341111 + "x": 17600.706344663235, + "y": 19674.076432894675 }, "targetPosition": { - "x": 19771.152963468092, - "y": 18250.396819879497 + "x": 17236.64869719451, + "y": 19409.57306936306 }, "floatingObject": { "isPinned": false, @@ -11217,17 +11565,17 @@ { "type": "Feature Contribution Claim", "name": "User Defined Variables and Code New Features", - "config": "{\n}", + "config": "{}", "project": "Governance", "id": "9d526dfa-522d-463f-9569-383be672d116", "savedPayload": { "position": { - "x": 19360.05750752892, - "y": 18433.428309263607 + "x": 16825.553241255337, + "y": 19592.60455874717 }, "targetPosition": { - "x": 19771.152963468092, - "y": 18250.396819879497 + "x": 17236.64869719451, + "y": 19409.57306936306 }, "floatingObject": { "isPinned": false, @@ -11283,12 +11631,12 @@ "id": "7f8f1fec-5a45-41c1-a297-a92a22b3e524", "savedPayload": { "position": { - "x": 19771.152963468092, - "y": 18250.396819879497 + "x": 17236.64869719451, + "y": 19409.57306936306 }, "targetPosition": { - "x": 19818.190771938534, - "y": 17802.861966963774 + "x": 17283.68650566495, + "y": 18962.038216447338 }, "floatingObject": { "isPinned": false, @@ -11320,12 +11668,12 @@ "id": "ffeb7ead-1cfd-4c0f-802a-64ab3d0ca55b", "savedPayload": { "position": { - "x": 18995.99986006019, - "y": 18168.924945731993 + "x": 16461.495593786607, + "y": 19328.101195215557 }, "targetPosition": { - "x": 19407.095315999362, - "y": 17985.893456347883 + "x": 16872.59104972578, + "y": 19145.069705831447 }, "floatingObject": { "isPinned": false, @@ -11375,12 +11723,12 @@ "id": "5cbec4c5-0432-4cf9-b105-34342ca701db", "savedPayload": { "position": { - "x": 19407.095315999362, - "y": 17985.893456347883 + "x": 16872.59104972578, + "y": 19145.069705831447 }, "targetPosition": { - "x": 19818.190771938534, - "y": 17802.861966963774 + "x": 17283.68650566495, + "y": 18962.038216447338 }, "floatingObject": { "isPinned": false, @@ -11403,12 +11751,12 @@ "id": "3ed14538-feda-4865-be79-3908e4ff44e8", "savedPayload": { "position": { - "x": 19636.16194820417, - "y": 17670.610285197967 + "x": 17101.65768193059, + "y": 18829.78653468153 }, "targetPosition": { - "x": 19818.190771938534, - "y": 17802.861966963774 + "x": 17283.68650566495, + "y": 18962.038216447338 }, "floatingObject": { "isPinned": false, @@ -11426,12 +11774,12 @@ "id": "647eddb0-6989-49ca-9288-8aaade078bec", "savedPayload": { "position": { - "x": 19818.190771938534, - "y": 17802.861966963774 + "x": 17283.68650566495, + "y": 18962.038216447338 }, "targetPosition": { - "x": 19865.228580408977, - "y": 17355.32711404805 + "x": 17330.724314135394, + "y": 18514.503363531614 }, "floatingObject": { "isPinned": false, @@ -11449,12 +11797,12 @@ "id": "704ea112-7592-4d37-b300-9227448bfe9f", "savedPayload": { "position": { - "x": 19865.228580408977, - "y": 17355.32711404805 + "x": 17330.724314135394, + "y": 18514.503363531614 }, "targetPosition": { - "x": 19501.17093294025, - "y": 17090.823750516436 + "x": 16966.666666666668, + "y": 18250 }, "floatingObject": { "isPinned": false, @@ -11472,7 +11820,7 @@ "financialPrograms": { "type": "Financial Programs", "name": "New Financial Programs", - "config": "{\n \"percentage\": 2\n}", + "config": "{\n \"percentage\": 0\n}", "project": "Governance", "stakingProgram": { "type": "Staking Program", @@ -11588,12 +11936,12 @@ "id": "182c1476-f2a8-4c5a-8173-f37050aab5d5", "savedPayload": { "position": { - "x": 19408.46583462777, - "y": 17376.14070540498 + "x": 16873.961568354185, + "y": 18535.316954888545 }, "targetPosition": { - "x": 19501.17093294025, - "y": 17090.823750516436 + "x": 16966.666666666668, + "y": 18250 }, "floatingObject": { "isPinned": false, @@ -11611,12 +11959,12 @@ "id": "9b72df20-a4f0-4023-ae17-c46a64920716", "savedPayload": { "position": { - "x": 19501.17093294025, - "y": 17090.823750516436 + "x": 16966.666666666668, + "y": 18250 }, "targetPosition": { - "x": 19201.17093294025, - "y": 17090.823750516436 + "x": 16666.666666666668, + "y": 18250 }, "floatingObject": { "isPinned": false, @@ -11638,12 +11986,12 @@ "id": "a9459b1f-80a5-4676-a9eb-a21a11e32c50", "savedPayload": { "position": { - "x": 18901.17093294025, - "y": 17090.823750516436 + "x": 16366.666666666668, + "y": 18250 }, "targetPosition": { - "x": 19201.17093294025, - "y": 17090.823750516436 + "x": 16666.666666666668, + "y": 18250 }, "floatingObject": { "isPinned": false, @@ -11661,17 +12009,17 @@ "id": "142f5de2-3762-4f55-a839-22eac5c03c8f", "savedPayload": { "position": { - "x": 19201.17093294025, - "y": 17090.823750516436 + "x": 16666.666666666668, + "y": 18250 }, "targetPosition": { - "x": 19201.17093294025, - "y": 17090.823750516436 + "x": 16666.666666666668, + "y": 18250 }, "floatingObject": { "isPinned": false, "isFrozen": false, - "isCollapsed": false, + "isCollapsed": true, "angleToParent": 1, "distanceToParent": 3, "arrangementStyle": 0 diff --git a/setup.js b/setup.js index 6384f38e2..3651482fc 100644 --- a/setup.js +++ b/setup.js @@ -2,6 +2,7 @@ const path = require("path"); const process = require("process"); const { exec } = require("child_process"); const systemCheck = require('./Launch-Scripts/system-check') +const platform = require('os').platform(); // Possible values are: 'aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', and 'win32'. // Check system is set up correctly systemCheck(); @@ -33,11 +34,15 @@ let nodeModulesDirs = [ path.join( process.cwd(), "Projects", "Foundations", "TS", "Bot-Modules", "Trading-Bot", "Announcements"), path.join( process.cwd(), "Projects", "Foundations", "TS", "Bot-Modules", "Trading-Bot", "Low-Frequency-Trading", "APIs"), path.join( process.cwd(), "Projects", "Foundations", "TS", "Task-Modules"), - /* Aug-27-21 - TensorFlow dependency integration undergoing modifications. Should be resolved within a day or two: path.join( process.cwd(), "Projects", "TensorFlow", "TS", "Bot-Modules", "Learning-Bot", "Low-Frequency-Learning") - */ ]; +// Check if WinOS because extra dependencies may be required for tfjs: +var tfjsWinInstallFlag = false; +if (platform === 'win32') { // *Note: win32 == win32 || win64 + tfjsWinInstallFlag = true; +} + console.log(''); console.log("Installing node dependencies at the following directories:"); console.log(''); @@ -57,9 +62,31 @@ for (let dir of nodeModulesDirs) { console.log("There was an error installing some dependencies error: "); console.log(''); console.log( error ); + if (tfjsWinInstallFlag == true && dir == path.join(process.cwd(), "Projects", "TensorFlow", "TS", "Bot-Modules", "Learning-Bot", "Low-Frequency-Learning")) { + tfjsWinInstall(); + } return; } console.log(''); console.log( stdout ); }); -}; \ No newline at end of file +}; + + +/* If WinOS && error with tfjs installation: + * This is a well known and documented issue with @Tensorflow/tfjs-node installation on WinOS. + * npm's windows-build-tools via: `npm install --global --production windows-build-tools` && + * `npm install -g node-gyp` can sometimes correct the issue but not always depending on the + * version and options the user defined when installing npm/nodejs. + * The best reliable way to correct that I (Pluvtech) have found to work on many versions of WinOS + * is to reinstall nodejs and select to install chocolatey during the installation configuration. + */ +function tfjsWinInstall() { + console.log("\n*** Note to Windows Users Regarding the Superalgos TensorFlow Project ***"); + console.log("If you have no other errors with this setup script and do not wish to use the TensorFlow Project:\nThen all is successful with your Superalgos setup and you may proceed to use the software."); + console.log("\nIf you do wish to install the @Tensorflow/tfjs-node modules required for use with the Superalgos TensorFlow Project:"); + console.log("In this case it is likely your system is missing some dependencies required to build the TensorFlow (tfjs-node) bindings and you will need to follow the below steps:"); + console.log("\n1.) Reinstall node.js from https://nodejs.org/en/download/ @Version 14.17.5 or higher.\nDuring installation, when you arrive at the 'Tools for Native Modules' screen you need to select the box to:\n\t'Automatically install the necessary tools...Chocolatey...'"); + console.log("Doing this will cause a pop-up script in a new window which will install many npm/node tools and dependencies for use within the WinOS ecosystem."); + console.log("2.) When the installations finally complete you need to navigate back to your Superalgos directory and run `node setup` again.\n"); +} \ No newline at end of file