Skip to content

Commit

Permalink
Refactor DestopApp to SocialTradeApp
Browse files Browse the repository at this point in the history
  • Loading branch information
NAmorim committed Nov 26, 2022
1 parent 91d21c3 commit 1044a0f
Show file tree
Hide file tree
Showing 31 changed files with 63 additions and 62 deletions.
2 changes: 1 addition & 1 deletion DesktopReact/Client/webAppInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.newWebAppInterface = function newWebAppInterface() {

switch (messageHeader.networkService) {
case 'Social Graph': {
return await DK.desktopApp.p2pNetworkClient.socialGraphNetworkServiceClient.sendMessage(messageHeader)
return await ST.socialTradeApp.p2pNetworkClient.socialGraphNetworkServiceClient.sendMessage(messageHeader)
}
case 'Trading Signals': {
break
Expand Down
16 changes: 8 additions & 8 deletions DesktopReact/DesktopAppBackend.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
exports.newDesktopAppBackend = function newDesktopAppBackend() {
exports.newSocialTradingAppBackend = function newSocialTradingAppBackend() {
/*
The DK object is accessible everywhere at the Superalgos Desktop App.
The ST object is accessible everywhere at the Superalgos Desktop App.
It provides access to all modules built for this App.
*/
global.DK = {}
global.ST = {}
/*
The SA object is accessible everywhere at the Superalgos Desktop App.
It provides access to all modules built for Superalgos in general.
Expand All @@ -19,7 +19,7 @@ It provides access to all modules built for this App.
run: run
}

DK.desktopApp = thisObject
ST.socialTradeApp = thisObject

return thisObject

Expand All @@ -43,7 +43,7 @@ It provides access to all modules built for this App.
*/
let MULTI_PROJECT = require('../MultiProject.js');
let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject()
MULTI_PROJECT_MODULE.initialize(DK, 'DK')
MULTI_PROJECT_MODULE.initialize(ST, 'ST')
MULTI_PROJECT_MODULE.initialize(SA, 'SA')
/*
Setting up external dependencies.
Expand Down Expand Up @@ -118,12 +118,12 @@ It provides access to all modules built for this App.
These are the Network Interfaces by which the Web App interacts with this Desktop Client.
*/
let express = require('./backend/src/expressServer.js')
express.DesktopBackend(DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort, SA, DK);
console.log(`express Interface ................................................ Listening at port ${DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort}`);
express.DesktopBackend(ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort, SA, ST);
console.log(`express Interface ................................................ Listening at port ${ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort}`);
}
}
}


let app = this.newDesktopAppBackend();
let app = this.newSocialTradingAppBackend();
app.run();
4 changes: 2 additions & 2 deletions DesktopReact/DesktopAppFrontend.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.newDesktopAppFrontend = function newDesktopAppFrontend() {
exports.newSocialTradingAppFrontend = function newSocialTradingAppFrontend() {

let thisObject = {
run: run
Expand All @@ -21,5 +21,5 @@ exports.newDesktopAppFrontend = function newDesktopAppFrontend() {
}
}

let app = this.newDesktopAppFrontend();
let app = this.newSocialTradingAppFrontend();
app.run();
4 changes: 2 additions & 2 deletions DesktopReact/backend/src/expressServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const compression = require('compression');
const cors = require('cors');
const routes = require('./routes');

exports.DesktopBackend = (port, SA, DK) => {
exports.DesktopBackend = (port, SA, ST) => {
try {

let server;
Expand All @@ -12,7 +12,7 @@ exports.DesktopBackend = (port, SA, DK) => {

app.use(function (req, res, next) {
global.SA = SA;
global.webAppInterface = DK.desktopApp.webAppInterface;
global.webAppInterface = ST.socialTradeApp.webAppInterface;
next();
});

Expand Down
4 changes: 2 additions & 2 deletions DesktopReact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"presetup": "git checkout develop && git pull upstream develop",
"setup": "node setup noShortcuts && node tf_setup.js",
"postsetup": "npm start",
"startDesktopReactBackend": "node DesktopAppBackend",
"startDesktopReactFrontend": "node DesktopAppFrontend"
"startDesktopReactBackend": "node SocialTradingAppBackend",
"startDesktopReactFrontend": "node SocialTradingAppFrontend"
},
"babel": {
"presets": [
Expand Down
22 changes: 11 additions & 11 deletions Environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ exports.newEnvironment = function () {
PLATFORM_WEB_SOCKETS_INTERFACE_PORT: 18041,
NETWORK_WEB_SOCKETS_INTERFACE_PORT: 18042,
DASHBOARDS_WEB_SOCKETS_INTERFACE_PORT: 18043,
DESKTOP_WEB_SOCKETS_INTERFACE_PORT: 16041,
DESKTOP_WEB_SOCKETS_INTERFACE_HOST: 'localhost',
SOCIALTRADE_WEB_SOCKETS_INTERFACE_PORT: 16041,
SOCIALTRADE_WEB_SOCKETS_INTERFACE_HOST: 'localhost',
PLATFORM_HTTP_INTERFACE_PORT: 34248,
DESKTOP_HTTP_INTERFACE_PORT: 33248,
SOCIALTRADE_HTTP_INTERFACE_PORT: 33248,
NETWORK_HTTP_INTERFACE_PORT: 31248,
PATH_TO_DATA_STORAGE: path.join(basePath, './Platform/My-Data-Storage'),
PATH_TO_PROJECTS: path.join(basePath, './Projects'),
Expand All @@ -32,15 +32,19 @@ exports.newEnvironment = function () {
PATH_TO_PROJECTS_REQUIRED: path.join(basePath, './Projects'),
PATH_TO_PROJECT_SCHEMA: path.join(basePath, './Projects/ProjectsSchema.json'),
PATH_TO_PLATFORM: path.join(basePath, './Platform'),
PATH_TO_DESKTOP: './Desktop',
PATH_TO_SOCIALTRADE: './SocialTrade',
PATH_TO_DEFAULT_WORKSPACE: path.join(basePath, './Plugins/Foundations/Workspaces'),
PATH_TO_MY_WORKSPACES: path.join(basePath, './Platform/My-Workspaces'),
PATH_TO_SECRETS: path.join(basePath, './My-Secrets'),
PATH_TO_FONTS: path.join(basePath, './Platform/WebServer/Fonts'),
PATH_TO_BITCOIN_FACTORY: path.join(basePath, './Bitcoin-Factory'),
DESKTOP_APP_SIGNING_ACCOUNT: 'Social-Trading-Desktop-App-1',
DESKTOP_APP_MAX_OUTGOING_PEERS: 1,
DESKTOP_APP_MAX_OUTGOING_START_PEERS: 0,
SOCIALTRADE_APP_SIGNING_ACCOUNT: 'Social-Trading-Desktop-App-1',
SOCIALTRADE_APP_MAX_OUTGOING_PEERS: 5,
SOCIALTRADE_APP_MAX_OUTGOING_START_PEERS: 1,
SOCIALTRADE_TARGET_NETWORK_TYPE: 'P2P Network',
SOCIALTRADE_TARGET_NETWORK_CODENAME: 'Testnet',
SOCIALTRADE_DEFAULT_SOCIAL_PERSONA: 'Social-Persona-1',
SOCIALTRADE_DEFAULT_SOCIAL_TRADING_BOT: 'Social-Trading-Bot-2',
TASK_SERVER_APP_MAX_OUTGOING_PEERS: 1,
TASK_SERVER_APP_MAX_OUTGOING_START_PEERS: 1,
MOBILE_APP_SIGNING_ACCOUNT: 'Social-Trading-Mobile-App-1',
Expand All @@ -50,10 +54,6 @@ exports.newEnvironment = function () {
P2P_NETWORK_NODE_MAX_INCOMING_CLIENTS: 1000,
P2P_NETWORK_NODE_MAX_INCOMING_PEERS: 0,
P2P_NETWORK_NODE_MAX_OUTGOING_PEERS: 0,
DESKTOP_TARGET_NETWORK_TYPE: 'P2P Network',
DESKTOP_TARGET_NETWORK_CODENAME: 'Testnet',
DESKTOP_DEFAULT_SOCIAL_PERSONA: 'Social-Persona-1',
DESKTOP_DEFAULT_SOCIAL_TRADING_BOT: 'Social-Trading-Bot-1',
NPM_NEEDED_VERSION: '5',
NODE_NEEDED_VERSION: '12',
GIT_NEEDED_VERSION: '2',
Expand Down
2 changes: 1 addition & 1 deletion Projects/ProjectsSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2105,7 +2105,7 @@
}
]
},
"DK": {
"ST": {
"globals": [],
"modules": [],
"utilities": []
Expand Down
8 changes: 4 additions & 4 deletions Projects/Social-Trading/SA/Function-Libraries/UserProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ exports.newSocialTradingFunctionLibrariesUserProfile = function () {

switch (profileMessage.userAppType) {
case "Social Trading Desktop App": {
if (userProfile.userApps.desktopApps === undefined) {
userProfile.userApps.desktopApps = {
if (userProfile.userApps.socialTradeApp === undefined) {
userProfile.userApps.socialTradeApp = {
type: 'Desktop Apps',
name: 'New Desktop Apps',
project: 'User-Apps',
Expand All @@ -288,8 +288,8 @@ exports.newSocialTradingFunctionLibrariesUserProfile = function () {
id: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
config: '{}',
}
userProfile.userApps.desktopApps.socialTradingDesktopApps.push(targetNode)
targetNodeTypeCount = userProfile.userApps.desktopApps.socialTradingDesktopApps.length
userProfile.userApps.socialTradeApp.socialTradingDesktopApps.push(targetNode)
targetNodeTypeCount = userProfile.userApps.socialTradeApp.socialTradingDesktopApps.length
break
}
case "Social Trading Mobile App": {
Expand Down
2 changes: 1 addition & 1 deletion Projects/User-Apps/Schemas/App-Schema/desktop-apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"attachingRules": {
"compatibleTypes": "->User Apps->"
},
"propertyNameAtParent": "desktopApps",
"propertyNameAtParent": "socialTradeApp",
"childrenNodesProperties": [
{
"name": "socialTradingDesktopApps",
Expand Down
4 changes: 2 additions & 2 deletions Projects/User-Apps/Schemas/App-Schema/user-apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"action": "Add UI Object",
"actionProject": "Visual-Scripting",
"disableIfPropertyIsDefined": true,
"propertyToCheckFor": "desktopApps",
"propertyToCheckFor": "socialTradeApp",
"actionFunction": "payload.executeAction",
"label": "Add Desktop Apps",
"relatedUiObject": "Desktop Apps",
Expand Down Expand Up @@ -63,7 +63,7 @@
"propertyNameAtParent": "userApps",
"childrenNodesProperties": [
{
"name": "desktopApps",
"name": "socialTradeApp",
"type": "node",
"childType": "Desktop Apps",
"project": "User-Apps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.newHttpInterface = function newHttpInterface() {
}

function initialize() {
let port = DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort
let port = ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort
/*
We will create an HTTP Server and leave it running forever.
*/
Expand Down Expand Up @@ -44,11 +44,11 @@ exports.newHttpInterface = function newHttpInterface() {
case 'ClientNode':
{
let clientNode = {
name: DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.name,
type: DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.type,
id: DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.id,
project: DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.project,
config: JSON.stringify(DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config)
name: ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.name,
type: ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.type,
id: ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.id,
project: ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.project,
config: JSON.stringify(ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config)
}
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(clientNode), httpResponse)
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exports.newWebAppInterface = function newWebAppInterface() {

switch (messageHeader.networkService) {
case 'Social Graph': {
let response = await DK.desktopApp.p2pNetworkClient.socialGraphNetworkServiceClient.sendMessage(messageHeader)
let response = await ST.socialTradeApp.p2pNetworkClient.socialGraphNetworkServiceClient.sendMessage(messageHeader)
return response
}
case 'Trading Signals': {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports.newWebSocketsInterface = function newWebSocketsInterface() {
}

function initialize() {
let port = DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webSocketsPort
let port = ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webSocketsPort
socketServer = new SA.nodeModules.ws.Server({ port: port })
setUpWebSocketServer()
}
Expand Down Expand Up @@ -62,7 +62,7 @@ exports.newWebSocketsInterface = function newWebSocketsInterface() {
return
}

await DK.desktopApp.webAppInterface.sendMessage(messageHeader.payload)
await ST.socialTradeApp.webAppInterface.sendMessage(messageHeader.payload)
.then(sendResponseToWebApp)
.catch(onError)

Expand Down
21 changes: 11 additions & 10 deletions Desktop/DesktopApp.js → SocialTrade/SocialTradeApp.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.newDesktopApp = function newDesktopApp() {
exports.newSocialTradingApp = function newSocialTradingApp() {

let thisObject = {
webSocketsInterface: undefined,
Expand All @@ -9,7 +9,7 @@ exports.newDesktopApp = function newDesktopApp() {
run: run
}

DK.desktopApp = thisObject
ST.socialTradeApp = thisObject

return thisObject

Expand Down Expand Up @@ -64,12 +64,13 @@ exports.newDesktopApp = function newDesktopApp() {
*/
thisObject.p2pNetworkClient = SA.projects.network.modules.p2pNetworkClient.newNetworkModulesP2PNetworkClient()
await thisObject.p2pNetworkClient.initialize(
global.env.DESKTOP_APP_SIGNING_ACCOUNT,
global.env.DESKTOP_TARGET_NETWORK_TYPE,
global.env.DESKTOP_TARGET_NETWORK_CODENAME,
global.env.DESKTOP_APP_MAX_OUTGOING_PEERS,
global.env.DESKTOP_APP_MAX_OUTGOING_START_PEERS,
thisObject.p2pNetworkInterface.eventReceived
global.env.SOCIALTRADE_APP_SIGNING_ACCOUNT,
global.env.SOCIALTRADE_TARGET_NETWORK_TYPE,
global.env.SOCIALTRADE_TARGET_NETWORK_CODENAME,
global.env.SOCIALTRADE_APP_MAX_OUTGOING_PEERS,
global.env.SOCIALTRADE_APP_MAX_OUTGOING_START_PEERS,
thisObject.p2pNetworkInterface.eventReceived,
[]
)
}

Expand All @@ -79,11 +80,11 @@ exports.newDesktopApp = function newDesktopApp() {
*/
thisObject.webSocketsInterface = WEB_SOCKETS_INTERFACE_MODULE.newWebSocketsInterface()
thisObject.webSocketsInterface.initialize()
console.log('Desktop Client Web Sockets Interface ......................................... Listening at port ' + DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webSocketsPort)
console.log('Desktop Client Web Sockets Interface ......................................... Listening at port ' + ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webSocketsPort)

thisObject.httpInterface = HTTP_INTERFACE_MODULE.newHttpInterface()
thisObject.httpInterface.initialize()
console.log('Desktop Client Http Interface ................................................ Listening at port ' + DK.desktopApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort)
console.log('Desktop Client Http Interface ................................................ Listening at port ' + ST.socialTradeApp.p2pNetworkClient.p2pNetworkClientIdentity.node.config.webPort)
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions DesktopRoot.js → SocialTradeRoot.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
exports.newDesktopRoot = function newDesktopRoot() {
exports.newSocialTradeRoot = function newSocialTradeRoot() {
/*
This module represents the execution root of the Desktop App.
We use this module that is outside the Desktop folder to
Expand All @@ -12,10 +12,10 @@ exports.newDesktopRoot = function newDesktopRoot() {

async function run(debugSettings) {
/*
The DK object is accessible everywhere at the Superalgos Desktop App.
The ST object is accessible everywhere at the Superalgos Desktop App.
It provides access to all modules built for this App.
*/
global.DK = {}
global.ST = {}
/*
The SA object is accessible everywhere at the Superalgos Desktop App.
It provides access to all modules built for Superalgos in general.
Expand All @@ -38,7 +38,7 @@ exports.newDesktopRoot = function newDesktopRoot() {
*/
let MULTI_PROJECT = require('./MultiProject.js')
let MULTI_PROJECT_MODULE = MULTI_PROJECT.newMultiProject()
MULTI_PROJECT_MODULE.initialize(DK, 'DK')
MULTI_PROJECT_MODULE.initialize(ST, 'ST')
MULTI_PROJECT_MODULE.initialize(SA, 'SA')
/*
Setting up external dependencies.
Expand Down Expand Up @@ -74,8 +74,8 @@ exports.newDesktopRoot = function newDesktopRoot() {
run()

async function run() {
DK.app = require('./Desktop/DesktopApp.js').newDesktopApp()
await DK.app.run()
ST.app = require('./SocialTrade/SocialTradeApp.js').newSocialTradingApp()
await ST.app.run()
console.log('Superalgos Desktop App is Running!')
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"dist": "electron-builder -c build/electron-builder.json",
"postinstall": "electron-builder install-app-deps",
"startNetwork": "node network",
"startDesktop": "node desktop",
"startSocialTrade": "node socialTrade",
"installDesktopReact": "cd ./DesktopReact && npm ci",
"startLocalDesktopReact": "start npm run startNetwork && cd ./DesktopReact && start npm run startDesktopReactBackend && start npm run startDesktopReactFrontend",
"startDesktopReact": "cd ./DesktopReact && start npm run startDesktopReactBackend && start npm run startDesktopReactFrontend",
Expand Down
4 changes: 2 additions & 2 deletions desktop.js → socialTrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ This module represents the Nodejs command that users have to start the Desktop A
*/

let APP_ROOT = require('./DesktopRoot.js')
let APP_ROOT_MODULE = APP_ROOT.newDesktopRoot()
let APP_ROOT = require('./SocialTradeRoot.js')
let APP_ROOT_MODULE = APP_ROOT.newSocialTradeRoot()
APP_ROOT_MODULE.run()

0 comments on commit 1044a0f

Please sign in to comment.