Merge branch 'develop' of https://github.com/Superalgos/Superalgos into develop

This commit is contained in:
Julian Molina committed 2021-09-01 20:01:10 +02:00
commit b55439d3a9
40 files changed
+2029 -632

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": "C:\\Superalgos"
}
],
"settings": {
"search.maintainFileSearchCache": true
}
}
+10
View File
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": "C:\\Superalgos"
}
],
"settings": {
"search.maintainFileSearchCache": true
}
}
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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
+26
View File
@@ -0,0 +1,26 @@
exports.newDesktopApp = function newDesktopApp() {
let thisObject = {
run: run
}
return thisObject
function run() {
/*
Let's start the Network Interfaces
*/
DK.webSocketsClient = SA.projects.network.modules.webSocketsClient.newNetworkModulesWebSocketsClient()
DK.webSocketsClient.initialize()
return
start()
async function start() {
let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph()
await socialGraphService.initialize()
}
}
}
+1 -1
View File
@@ -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',
+13 -12
View File
@@ -2,20 +2,21 @@ exports.newEnvironment = function () {
let thisObject = {
WEB_SERVER_URL: 'localhost',
WEB_SOCKETS_INTERFACE_PORT: 18041,
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
+3
View File
@@ -5,6 +5,9 @@
},
{
"path": "C:\\Superalgos\\Projects\\Network"
},
{
"path": "C:\\Superalgos\\Projects\\Social-Trading"
}
],
"settings": {}
+17 -46
View File
@@ -1,53 +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')
}
start()
start()
async function start() {
let socialGraphService = NT.projects.socialTrading.modules.socialGraph.newSocialGraph()
await socialGraphService.initialize()
}
async function start() {
let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph()
await socialGraphService.initialize()
}
}
-87
View File
@@ -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()
}
}
File diff suppressed because it is too large. Load diff
@@ -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
-18
View File
@@ -1,18 +0,0 @@
exports.newNetworkGlobalsMemory = function () {
/*
Here is the Data we are going to keep in memory.
*/
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.
},
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.
}
}
return thisObject
}
@@ -0,0 +1,173 @@
exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSocketsInterface() {
let thisObject = {
initialize: initialize,
finalize: finalize
}
let socketServer
let clientInterface
let peerInterface
return thisObject
function finalize() {
socketServer = undefined
clientInterface = undefined
peerInterface = undefined
}
function initialize() {
socketServer = new SA.nodeModules.ws.Server({ port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT })
clientInterface = NT.projects.socialTrading.modules.clientInterface.newSocialTradingModulesClientInterface()
peerInterface = NT.projects.socialTrading.modules.peerInterface.newSocialTradingModulesPeerInterface()
setUpWebSocketServer()
}
function setUpWebSocketServer() {
try {
socketServer.on('connection', onConnection)
function onConnection(socket) {
let caller = {}
socket.on('message', onMenssage)
async function onMenssage(message) {
try {
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.
*/
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": {
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
}
}
} catch (err) {
console.log('[ERROR] Web Sockets Interface -> setUpWebSocketServer -> err.stack = ' + 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.socialTrading.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] Web Sockets Interface -> setUpWebSocketServer -> err.stack = ' + err.stack)
}
}
}
@@ -0,0 +1,101 @@
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('ws://' + 'localhost' + ':' + global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT)
//networkInterface = SA.projects.socialTrading.modules.networkInterface.newSocialTradingModulesNetworkInterface()
setUpWebsocketClient()
}
function setUpWebsocketClient() {
try {
let handshakeDone = false
socketClient.onopen = () => { onConnection() }
socketClient.onmessage = socketMessage => { onMenssage(socketMessage) }
socketClient.onerror = err => { onError(err) }
function onConnection() {
/*
Send Handshake Message
*/
socketClient.send('Handshake Message')
console.log('Handshake Message Sent')
}
async function onMenssage(socketMessage) {
try {
let response = JSON.parse(socketMessage.data)
/*
Chack if we are waiting for the Handshake response.
*/
if (handshakeDone === false) {
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 -> err.stack = ' + err.stack)
}
}
function onError(err) {
console.log('[ERROR] Web Sockets Client -> onError -> err.message = ' + err.message)
console.log('[ERROR] Web Sockets Client -> onError -> err.stack = ' + err.stack)
}
} catch (err) {
console.log('[ERROR] Web Sockets Client -> setUpWebsocketClient -> err.stack = ' + err.stack)
}
}
function sendMessage(message, 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
}
}
}
+57 -17
View File
@@ -1271,18 +1271,46 @@
{
"name": "Network",
"propertyName": "network",
"NT": {
"globals": [],
"modules": [
{
"name": "Web Sockets Interface",
"propertyName": "webSocketsInterface",
"functionName": "newNetworkModulesWebSocketsInterface",
"fileName": "WebSocketsInterface.js"
}
],
"utilities": []
},
"SA": {
"globals": [],
"modules": [
{
"name": "Web Sockets Client",
"propertyName": "webSocketsClient",
"functionName": "newNetworkModulesWebSocketsClient",
"fileName": "WebSocketsClient.js"
}
],
"utilities": []
}
},
{
"name": "Social-Trading",
"propertyName": "socialTrading",
"NT": {
"globals": [
{
"name": "Query Constants",
"propertyName": "queryConstants",
"functionName": "newNetworkGlobalsQueryConstants",
"functionName": "newSocialTradingGlobalsQueryConstants",
"fileName": "QueryConstants.js"
},
{
"name": "Memory",
"propertyName": "memory",
"functionName": "newNetworkGlobalsMemory",
"functionName": "newSocialTradingGlobalsMemory",
"fileName": "Memory.js"
}
],
@@ -1290,93 +1318,105 @@
{
"name": "Bot Profile Stats",
"propertyName": "queriesBotProfileStats",
"functionName": "newNetworkModulesQueriesBotProfileStats",
"functionName": "newSocialTradingModulesQueriesBotProfileStats",
"fileName": "Queries/BotProfileStats.js"
},
{
"name": "User Profile Stats",
"propertyName": "queriesUserProfileStats",
"functionName": "newNetworkModulesQueriesUserProfileStats",
"functionName": "newSocialTradingModulesQueriesUserProfileStats",
"fileName": "Queries/UserProfileStats.js"
},
{
"name": "Profile Posts",
"propertyName": "queriesProfilePosts",
"functionName": "newNetworkModulesQueriesProfilePosts",
"functionName": "newSocialTradingModulesQueriesProfilePosts",
"fileName": "Queries/ProfilePosts.js"
},
{
"name": "Profile Followers",
"propertyName": "queriesProfileFollowers",
"functionName": "newNetworkModulesQueriesProfileFollowers",
"functionName": "newSocialTradingModulesQueriesProfileFollowers",
"fileName": "Queries/ProfileFollowers.js"
},
{
"name": "Profile Following",
"propertyName": "queriesProfileFollowing",
"functionName": "newNetworkModulesQueriesProfileFollowing",
"functionName": "newSocialTradingModulesQueriesProfileFollowing",
"fileName": "Queries/ProfileFollowing.js"
},
{
"name": "Post Replies",
"propertyName": "queriesPostReplies",
"functionName": "newNetworkModulesQueriesPostReplies",
"functionName": "newSocialTradingModulesQueriesPostReplies",
"fileName": "Queries/PostReplies.js"
},
{
"name": "Events",
"propertyName": "queriesEvents",
"functionName": "newNetworkModulesQueriesEvents",
"functionName": "newSocialTradingModulesQueriesEvents",
"fileName": "Queries/Events.js"
},
{
"name": "User Profile",
"propertyName": "socialGraphUserProfile",
"functionName": "newNetworkModulesSocialGraphUserProfile",
"functionName": "newSocialTradingModulesSocialGraphUserProfile",
"fileName": "Social-Graph/UserProfile.js"
},
{
"name": "Bot Profile",
"propertyName": "socialGraphBotProfile",
"functionName": "newNetworkModulesSocialGraphBotProfile",
"functionName": "newSocialTradingModulesSocialGraphBotProfile",
"fileName": "Social-Graph/BotProfile.js"
},
{
"name": "Post",
"propertyName": "socialGraphPost",
"functionName": "newNetworkModulesSocialGraphPost",
"functionName": "newSocialTradingModulesSocialGraphPost",
"fileName": "Social-Graph/Post.js"
},
{
"name": "Social Graph",
"propertyName": "socialGraph",
"functionName": "newNetworkModulesSocialGraph",
"functionName": "newSocialTradingModulesSocialGraph",
"fileName": "SocialGraph.js"
},
{
"name": "Bootstrap",
"propertyName": "bootstrap",
"functionName": "newNetworkModulesBootstrap",
"functionName": "newSocialTradingModulesBootstrap",
"fileName": "Bootstrap.js"
},
{
"name": "Query",
"propertyName": "Query",
"functionName": "newNetworkModulesQuery",
"functionName": "newSocialTradingModulesQuery",
"fileName": "Query.js"
},
{
"name": "Event",
"propertyName": "event",
"functionName": "newNetworkModulesEvent",
"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"
}
]
@@ -0,0 +1,19 @@
exports.newSocialTradingGlobalsMemory = function () {
/*
Here is the Data we are going to keep in memory.
*/
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.
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.
}
}
return thisObject
}
@@ -1,4 +1,4 @@
exports.newNetworkGlobalsQueryConstants = function () {
exports.newSocialTradingGlobalsQueryConstants = function () {
let thisObject = {
INITIAL_INDEX_FIRST: 'First',
@@ -36,21 +36,22 @@ 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
let userProfile = NT.projects.network.modules.socialGraphUserProfile.newNetworkModulesSocialGraphUserProfile()
let userProfile = NT.projects.socialTrading.modules.socialGraphUserProfile.newSocialTradingModulesSocialGraphUserProfile()
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.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)
}
}
@@ -0,0 +1,208 @@
exports.newSocialTradingModulesClientInterface = function newSocialTradingModulesClientInterface() {
/*
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.socialTrading.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.socialTrading.modules.event.newSocialTradingModulesEvent()
event.initialize(eventReceived)
NT.projects.socialTrading.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,
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, userProfile) {
/*
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
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.socialTrading.modules.queriesQuery.newSocialTradingModulesQuery()
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
}
}
}
@@ -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.')
}
@@ -1,4 +1,4 @@
exports.newPeerInterface = function newPeerInterface() {
exports.newSocialTradingModulesPeerInterface = function newSocialTradingModulesPeerInterface() {
let thisObject = {
initialize: initialize,
@@ -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) {
@@ -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()
@@ -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 }
@@ -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 }
@@ -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 }
@@ -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 }
@@ -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) {
@@ -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
@@ -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,
@@ -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.')
}
@@ -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,
@@ -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()
}
}
@@ -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.')
}
+15 -8
View File
@@ -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",
+2 -1
View File
@@ -1,6 +1,7 @@
{
"dependencies": {
"node-fetch": "^2.6.1",
"web3": "^1.5.2"
"web3": "^1.5.2",
"ws": "^8.2.1"
}
}
+51
View File
@@ -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('./Desktop/DesktopApp.js').newDesktopApp()
DK.app.run()
console.log('Superalgos Desktop is Running.')
+52
View File
@@ -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.')
+30 -3
View File
@@ -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 );
});
};
};
/* 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");
}