Adding the Social Trading Project

This commit is contained in:
Luis Fernando Molina committed 2021-08-31 14:42:44 +02:00
1 parent cf3c1358e1
commit b47b9b3dcf
25 files changed
+270 -180

No files matched your search

+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 = DK.projects.network.modules.webSocketsClient.newDesktopModulesWebSocketsClient()
DK.webSocketsClient.initialize()
return
start()
async function start() {
let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph()
await socialGraphService.initialize()
}
}
}
+3
View File
@@ -5,6 +5,9 @@
},
{
"path": "C:\\Superalgos\\Projects\\Network"
},
{
"path": "C:\\Superalgos\\Projects\\Social-Trading"
}
],
"settings": {}
+1 -1
View File
@@ -16,7 +16,7 @@ exports.newNetworkNode = function newNetworkNode() {
start()
async function start() {
let socialGraphService = NT.projects.network.modules.socialGraph.newSocialGraph()
let socialGraphService = NT.projects.socialTrading.modules.socialGraph.newSocialGraph()
await socialGraphService.initialize()
}
@@ -19,8 +19,8 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock
function initialize() {
socketServer = new SA.nodeModules.ws.Server({ port: global.env.NETWORK_WEB_SOCKETS_INTERFACE_PORT })
clientInterface = NT.projects.network.modules.clientInterface.newNetworkModulesClientInterface()
peerInterface = NT.projects.network.modules.peerInterface.newNetworkModulesPeerInterface()
clientInterface = NT.projects.socialTrading.modules.clientInterface.newSocialTradingModulesClientInterface()
peerInterface = NT.projects.socialTrading.modules.peerInterface.newSocialTradingModulesPeerInterface()
setUpWebSocketServer()
}
@@ -144,7 +144,7 @@ exports.newNetworkModulesWebSocketsInterface = function newNetworkModulesWebSock
/*
The signature gives us the blockchain account, and the account the user profile.
*/
let userProfile = NT.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount)
let userProfile = NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount)
if (userProfile === undefined) {
let response = {
+121 -111
View File
@@ -1272,117 +1272,8 @@
"name": "Network",
"propertyName": "network",
"NT": {
"globals": [
{
"name": "Query Constants",
"propertyName": "queryConstants",
"functionName": "newNetworkGlobalsQueryConstants",
"fileName": "QueryConstants.js"
},
{
"name": "Memory",
"propertyName": "memory",
"functionName": "newNetworkGlobalsMemory",
"fileName": "Memory.js"
}
],
"globals": [],
"modules": [
{
"name": "Bot Profile Stats",
"propertyName": "queriesBotProfileStats",
"functionName": "newNetworkModulesQueriesBotProfileStats",
"fileName": "Queries/BotProfileStats.js"
},
{
"name": "User Profile Stats",
"propertyName": "queriesUserProfileStats",
"functionName": "newNetworkModulesQueriesUserProfileStats",
"fileName": "Queries/UserProfileStats.js"
},
{
"name": "Profile Posts",
"propertyName": "queriesProfilePosts",
"functionName": "newNetworkModulesQueriesProfilePosts",
"fileName": "Queries/ProfilePosts.js"
},
{
"name": "Profile Followers",
"propertyName": "queriesProfileFollowers",
"functionName": "newNetworkModulesQueriesProfileFollowers",
"fileName": "Queries/ProfileFollowers.js"
},
{
"name": "Profile Following",
"propertyName": "queriesProfileFollowing",
"functionName": "newNetworkModulesQueriesProfileFollowing",
"fileName": "Queries/ProfileFollowing.js"
},
{
"name": "Post Replies",
"propertyName": "queriesPostReplies",
"functionName": "newNetworkModulesQueriesPostReplies",
"fileName": "Queries/PostReplies.js"
},
{
"name": "Events",
"propertyName": "queriesEvents",
"functionName": "newNetworkModulesQueriesEvents",
"fileName": "Queries/Events.js"
},
{
"name": "User Profile",
"propertyName": "socialGraphUserProfile",
"functionName": "newNetworkModulesSocialGraphUserProfile",
"fileName": "Social-Graph/UserProfile.js"
},
{
"name": "Bot Profile",
"propertyName": "socialGraphBotProfile",
"functionName": "newNetworkModulesSocialGraphBotProfile",
"fileName": "Social-Graph/BotProfile.js"
},
{
"name": "Post",
"propertyName": "socialGraphPost",
"functionName": "newNetworkModulesSocialGraphPost",
"fileName": "Social-Graph/Post.js"
},
{
"name": "Social Graph",
"propertyName": "socialGraph",
"functionName": "newNetworkModulesSocialGraph",
"fileName": "SocialGraph.js"
},
{
"name": "Bootstrap",
"propertyName": "bootstrap",
"functionName": "newNetworkModulesBootstrap",
"fileName": "Bootstrap.js"
},
{
"name": "Query",
"propertyName": "Query",
"functionName": "newNetworkModulesQuery",
"fileName": "Query.js"
},
{
"name": "Event",
"propertyName": "event",
"functionName": "newNetworkModulesEvent",
"fileName": "Event.js"
},
{
"name": "Client Interface",
"propertyName": "clientInterface",
"functionName": "newNetworkModulesClientInterface",
"fileName": "ClientInterface.js"
},
{
"name": "Peer Interface",
"propertyName": "peerInterface",
"functionName": "newNetworkModulesPeerInterface",
"fileName": "PeerInterface.js"
},
{
"name": "Web Sockets Interface",
"propertyName": "webSocketsInterface",
@@ -1390,11 +1281,130 @@
"fileName": "WebSocketsInterface.js"
}
],
"utilities": []
}
},
{
"name": "Social-Trading",
"propertyName": "socialTrading",
"NT": {
"globals": [
{
"name": "Query Constants",
"propertyName": "queryConstants",
"functionName": "newSocialTradingGlobalsQueryConstants",
"fileName": "QueryConstants.js"
},
{
"name": "Memory",
"propertyName": "memory",
"functionName": "newSocialTradingGlobalsMemory",
"fileName": "Memory.js"
}
],
"modules": [
{
"name": "Bot Profile Stats",
"propertyName": "queriesBotProfileStats",
"functionName": "newSocialTradingModulesQueriesBotProfileStats",
"fileName": "Queries/BotProfileStats.js"
},
{
"name": "User Profile Stats",
"propertyName": "queriesUserProfileStats",
"functionName": "newSocialTradingModulesQueriesUserProfileStats",
"fileName": "Queries/UserProfileStats.js"
},
{
"name": "Profile Posts",
"propertyName": "queriesProfilePosts",
"functionName": "newSocialTradingModulesQueriesProfilePosts",
"fileName": "Queries/ProfilePosts.js"
},
{
"name": "Profile Followers",
"propertyName": "queriesProfileFollowers",
"functionName": "newSocialTradingModulesQueriesProfileFollowers",
"fileName": "Queries/ProfileFollowers.js"
},
{
"name": "Profile Following",
"propertyName": "queriesProfileFollowing",
"functionName": "newSocialTradingModulesQueriesProfileFollowing",
"fileName": "Queries/ProfileFollowing.js"
},
{
"name": "Post Replies",
"propertyName": "queriesPostReplies",
"functionName": "newSocialTradingModulesQueriesPostReplies",
"fileName": "Queries/PostReplies.js"
},
{
"name": "Events",
"propertyName": "queriesEvents",
"functionName": "newSocialTradingModulesQueriesEvents",
"fileName": "Queries/Events.js"
},
{
"name": "User Profile",
"propertyName": "socialGraphUserProfile",
"functionName": "newSocialTradingModulesSocialGraphUserProfile",
"fileName": "Social-Graph/UserProfile.js"
},
{
"name": "Bot Profile",
"propertyName": "socialGraphBotProfile",
"functionName": "newSocialTradingModulesSocialGraphBotProfile",
"fileName": "Social-Graph/BotProfile.js"
},
{
"name": "Post",
"propertyName": "socialGraphPost",
"functionName": "newSocialTradingModulesSocialGraphPost",
"fileName": "Social-Graph/Post.js"
},
{
"name": "Social Graph",
"propertyName": "socialGraph",
"functionName": "newSocialTradingModulesSocialGraph",
"fileName": "SocialGraph.js"
},
{
"name": "Bootstrap",
"propertyName": "bootstrap",
"functionName": "newSocialTradingModulesBootstrap",
"fileName": "Bootstrap.js"
},
{
"name": "Query",
"propertyName": "Query",
"functionName": "newSocialTradingModulesQuery",
"fileName": "Query.js"
},
{
"name": "Event",
"propertyName": "event",
"functionName": "newSocialTradingModulesEvent",
"fileName": "Event.js"
},
{
"name": "Client Interface",
"propertyName": "clientInterface",
"functionName": "newSocialTradingModulesClientInterface",
"fileName": "ClientInterface.js"
},
{
"name": "Peer Interface",
"propertyName": "peerInterface",
"functionName": "newSocialTradingModulesPeerInterface",
"fileName": "PeerInterface.js"
}
],
"utilities": [
{
"name": "Queries Validations",
"propertyName": "queriesValidations",
"functionName": "newNetworkUtilitiesQueriesValidations",
"functionName": "newSocialTradingUtilitiesQueriesValidations",
"fileName": "QueriesValidations.js"
}
]
@@ -1,4 +1,4 @@
exports.newNetworkGlobalsMemory = function () {
exports.newSocialTradingGlobalsMemory = function () {
/*
Here is the Data we are going to keep in memory.
*/
@@ -1,4 +1,4 @@
exports.newNetworkGlobalsQueryConstants = function () {
exports.newSocialTradingGlobalsQueryConstants = function () {
let thisObject = {
INITIAL_INDEX_FIRST: 'First',
@@ -41,7 +41,7 @@ exports.newBootstrap = function newBootstrap() {
let userProfileId = userProfilePlugin.id
let userHandle = config.signature.message
let userProfile = NT.projects.network.modules.socialGraphUserProfile.newNetworkModulesSocialGraphUserProfile()
let userProfile = NT.projects.socialTrading.modules.socialGraphUserProfile.newSocialTradingModulesSocialGraphUserProfile()
userProfile.initialize(
userProfileId,
userHandle,
@@ -49,9 +49,9 @@ exports.newBootstrap = function newBootstrap() {
ranking
)
NT.projects.network.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile)
NT.projects.network.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile)
NT.projects.network.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_ID.set(userProfileId, userProfile)
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_HANDLE.set(userHandle, userProfile)
NT.projects.socialTrading.globals.memory.maps.USER_PROFILES_BY_BLOCHAIN_ACCOUNT.set(blockchainAccount, userProfile)
}
}
@@ -1,4 +1,4 @@
exports.newNetworkModulesClientInterface = function newNetworkModulesClientInterface() {
exports.newSocialTradingModulesClientInterface = function newSocialTradingModulesClientInterface() {
/*
This module represents the Interface the Network Node have
with Network Clients connected to it. There are two things
@@ -106,7 +106,7 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter
We will not accept events that have already been processed.
*/
if (NT.projects.network.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) {
if (NT.projects.socialTrading.globals.memory.maps.EVENTS.get(eventReceived.eventId) !== undefined) {
let response = {
result: 'Error',
message: 'Client Interface Event Already Exists.'
@@ -117,9 +117,9 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter
Here we will process the event and change the state of the Social Graph.
*/
try {
let event = NT.projects.network.modules.event.newNetworkModulesEvent()
let event = NT.projects.socialTrading.modules.event.newSocialTradingModulesEvent()
event.initialize(eventReceived)
NT.projects.network.globals.memory.maps.EVENTS.set(eventReceived.eventId, event)
NT.projects.socialTrading.globals.memory.maps.EVENTS.set(eventReceived.eventId, event)
let response = {
result: 'Ok',
@@ -190,7 +190,7 @@ exports.newNetworkModulesClientInterface = function newNetworkModulesClientInter
Here we will process the query. This does not change the state of the Social Graph.
*/
try {
let query = NT.projects.network.modules.queriesQuery.newNetworkModulesQuery()
let query = NT.projects.socialTrading.modules.queriesQuery.newSocialTradingModulesQuery()
query.initialize(queryReceived)
return query.execute()
@@ -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.newNetworkModulesPeerInterface = function newNetworkModulesPeerInterface() {
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.')
}
+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('./Network/DesktopApp.js').newNetworkNode()
DK.app.run()
console.log('Superalgos Desktop is Running.')