Merge Develop into Master
This commit is contained in:
1 parent
2d7ed1d085
commit
2bb78c50fb
4223 files changed
+1207152
-16544
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 5.6 KiB |
@@ -828,7 +828,8 @@ width: 100%;
|
||||
|
||||
.docs-search-results-header-tabs-container {
|
||||
display: table;
|
||||
padding-left: 180px;
|
||||
text-align: right;
|
||||
align-content: right;
|
||||
margin-top: 20px;
|
||||
caret-color: transparent;
|
||||
}
|
||||
@@ -860,22 +861,23 @@ border-bottom: 3px solid #0295aa;
|
||||
/* Search Results Page Content */
|
||||
.docs-search-result-content {
|
||||
border-top: 1px solid #0295aa;
|
||||
margin-left: -180px;
|
||||
caret-color: transparent;
|
||||
text-align: left;
|
||||
align-content: left;
|
||||
}
|
||||
|
||||
.docs-search-result-content > div {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#tab1:checked ~ .docs-search-result-content #content1,
|
||||
#tab2:checked ~ .docs-search-result-content #content2,
|
||||
#tab3:checked ~ .docs-search-result-content #content3,
|
||||
#tab4:checked ~ .docs-search-result-content #content4,
|
||||
#tab5:checked ~ .docs-search-result-content #content5,
|
||||
#tab6:checked ~ .docs-search-result-content #content6,
|
||||
#tab7:checked ~ .docs-search-result-content #content7,
|
||||
#tab8:checked ~ .docs-search-result-content #content8 {
|
||||
#docs-tab1:checked ~ .docs-search-result-content #content1,
|
||||
#docs-tab2:checked ~ .docs-search-result-content #content2,
|
||||
#docs-tab3:checked ~ .docs-search-result-content #content3,
|
||||
#docs-tab4:checked ~ .docs-search-result-content #content4,
|
||||
#docs-tab5:checked ~ .docs-search-result-content #content5,
|
||||
#docs-tab6:checked ~ .docs-search-result-content #content6,
|
||||
#docs-tab7:checked ~ .docs-search-result-content #content7,
|
||||
#docs-tab8:checked ~ .docs-search-result-content #content8 {
|
||||
display: block;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
+103
-40
@@ -8,6 +8,7 @@
|
||||
<link rel="stylesheet" href="credits.css" type="text/css" charset="utf-8" />
|
||||
<link rel="stylesheet" href="tutorial.css" type="text/css" charset="utf-8" />
|
||||
<link rel="stylesheet" href="docs.css" type="text/css" charset="utf-8" />
|
||||
<link rel="stylesheet" href="governance.css" type="text/css" charset="utf-8" />
|
||||
<link rel="stylesheet" href="context-menu.css" type="text/css" charset="utf-8" />
|
||||
<link rel="stylesheet" href="font-awasome.css" type="text/css" />
|
||||
<link rel="stylesheet" href="prism.css" type="text/css" />
|
||||
@@ -32,7 +33,8 @@
|
||||
} catch (e) { console.error('CJ protection', e) }
|
||||
|
||||
try {
|
||||
loadSuperalgos();
|
||||
drawSplashText()
|
||||
loadSuperalgos()
|
||||
} catch (err) {
|
||||
console.log("[ERROR] UI can not be started. Please check that WebServer is running.", err);
|
||||
}
|
||||
@@ -48,21 +50,82 @@
|
||||
console.log('Error Resizing. ' + err.stack)
|
||||
}
|
||||
}
|
||||
|
||||
function drawSplashText() {
|
||||
const splashTextArray = [
|
||||
{
|
||||
"splashTextLine1Html": '<span class="credits-red">Superalgos is open source, forever free for everyone, and is constantly improving thanks to the involvement of contributors!</span>'
|
||||
,
|
||||
"splashTextLine2Html": 'You may contribute, earn tokens, and participate in the governance of the project, no matter what your set of skills may be! It\'s as simple as sharing what you build for yourself, submitting a review, fixing a bug, or even a typo in the Docs!'
|
||||
,
|
||||
"splashTextLine3Html": ''
|
||||
},
|
||||
{
|
||||
"splashTextLine1Html": '<span class="credits-red">Superalgos is a community of algo traders, sharing knowleadge, experience, and tools.</span>'
|
||||
,
|
||||
"splashTextLine2Html": 'We negotiate with exchanges and pass on benefits to all members. Become part of the Superalgos Community by making a small contribution to the open-source project!'
|
||||
,
|
||||
"splashTextLine3Html": ''
|
||||
},
|
||||
{
|
||||
"splashTextLine1Html": '<span class="credits-red">Superalgos is built on core values that we embrace wholeheartedly.</span>'
|
||||
,
|
||||
"splashTextLine2Html": 'The software features no ads and does not collect user or usage information of any kind. Our products and services are free of charge for everyone, and always will be.'
|
||||
,
|
||||
"splashTextLine3Html": 'Superalgos puts humans first. We respect your privacy, your freedom to use and contribute to our open-source project, and your freedom to innovate.'
|
||||
},
|
||||
{
|
||||
"splashTextLine1Html": '<span class="credits-red">Superalgos is permissionless.</span>'
|
||||
,
|
||||
"splashTextLine2Html": 'Don\'t like the UI, the icons, the Charting System, the Visual Designer, the Visual Debugger, the Docs, the Trading Bot, Indicators, Plotters? No problem!'
|
||||
,
|
||||
"splashTextLine3Html": 'Code or integrate libraries with your version of any component! We promise we will merge your work and provide it as an alternative to users. We believe in permissionless innovation! Users, not team members, are the final judges!'
|
||||
},
|
||||
{
|
||||
"splashTextLine1Html": '<span class="credits-red">Give Superalgos a star on GitHub!</span>'
|
||||
,
|
||||
"splashTextLine2Html": 'Stars make the repository easier to find on GitHub.com search. The more developers find us, the more people contribute to the project, and the better the system gets for everyone!'
|
||||
,
|
||||
"splashTextLine3Html": ''
|
||||
},
|
||||
{
|
||||
"splashTextLine1Html": '<span class="credits-red">Would you like to join the Superalgos\'s Developer Team?.</span>'
|
||||
,
|
||||
"splashTextLine2Html": 'Look around, find something that is missing and start coding! If you need help, ask in the chat groups to find a mentor!'
|
||||
,
|
||||
"splashTextLine3Html": 'Follow our motto: Just code it!'
|
||||
}
|
||||
]
|
||||
|
||||
let arrayIndex = Math.trunc(Math.random() * splashTextArray.length)
|
||||
let splashTextElement
|
||||
splashTextElement = document.getElementById('splash-text-line-1')
|
||||
splashTextElement.innerHTML = splashTextArray[arrayIndex].splashTextLine1Html
|
||||
splashTextElement = document.getElementById('splash-text-line-2')
|
||||
splashTextElement.innerHTML = splashTextArray[arrayIndex].splashTextLine2Html
|
||||
splashTextElement = document.getElementById('splash-text-line-3')
|
||||
splashTextElement.innerHTML = splashTextArray[arrayIndex].splashTextLine3Html
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body id="body" onload="loadCanvas()"
|
||||
style="overflow:hidden; background: url(Images/superalgos-platform.jpg); background-size: cover;"
|
||||
onresize="onResize()">
|
||||
<div id="contributors" class="credits">
|
||||
<p style="font-size: 120%;">Superalgos is <span class="credits-red">open source</span>, <span class="credits-red">forever free</span> for <span class="credits-red">everyone</span>, and is <span class="credits-red">constantly improving</span> thanks to the involvement of contributors:</p>
|
||||
<p style="font-size: 100%;">Luis Fernando Molina, Julian Molina, Andreja Cobeljic, Ira Miller, matbenitez, bearcanrun, nikolabjelo, 9808us, pmmax, suttridge, Basalt09, Mhnramin, 0xperez, infin1t3, benitezme, whtv, cozed-gh, Eduardo678-dotcom, Smidy13, teehanming, 64bittuning, joenij, apronotti, Noeljarillo, ssplatt, rico4dev, DougJCook, mane, Cordo-van-Saviour, CarnivalBen, Sil3ntLight, pisukesoramame, Edodi, harrellbm, CaptainJeff, Jeff Braun, Francisco J. Santillán, Norman, Viktoria B., Guillermo V., Daniel J., Javier A., Gustavo J., Romina GS, Pedro P., Thais M., Andrey M., Loui M., Natalia M., Bashar A., Carlos V., Diego M., Sebastian E., Bogdan P., Marko V., Igor S., Niksa K., Rodrigo M., Nicanor M., Mateo H., Lan T., Leon A., Uroš R., Filip M., Vladimir J. and Pavle B.</p>
|
||||
<p style="font-size: 120%;">Please, <span class="credits-red">give a star to the Superalgos repo at GitHub.com...</span> It helps other devs find the project!</p>
|
||||
<p id="credits-page-status-paragraph" class="credits-yellow">The UI is loading...</p>
|
||||
<div id="splash-text" class="credits">
|
||||
<p id="splash-text-line-1" style="font-size: 120%;"></p>
|
||||
<p id="splash-text-line-2" style="font-size: 120%;"></p>
|
||||
<p id="splash-text-line-3" style="font-size: 120%;"></p>
|
||||
<p id="splash-text-status-paragraph" class="credits-yellow">The UI is loading...</p>
|
||||
</div>
|
||||
<div id="masterApp"></div>
|
||||
<div id="canvasApp"></div>
|
||||
<div id="docs-space-div" class="docs-page" style="position:fixed; top:100000px; left:100000px"><div id="docs-content-div"></div></div>
|
||||
<div id="docs-space-div" class="docs-page" style="position:fixed; top:100000px; left:100000px">
|
||||
<div id="docs-content-div"></div>
|
||||
</div>
|
||||
<div id="governance-reports-space-div" class="governance-page" style="position:fixed; top:100000px; left:100000px">
|
||||
<div id="governance-content-div"></div>
|
||||
</div>
|
||||
<div id="chatApp" style="position:fixed; top:100000px; left:100000px">
|
||||
<iframe id="chatIFrame" style="border:none; " height="2000" width="900"></iframe>
|
||||
</div>
|
||||
@@ -77,21 +140,21 @@
|
||||
<tr>
|
||||
<td align="center">
|
||||
<label class="tutorial-font-small tutorial-stop-button"
|
||||
onclick="UI.projects.superalgos.spaces.tutorialSpace.stop()"
|
||||
onclick="UI.projects.education.spaces.tutorialSpace.stop()"
|
||||
value=""> Stop </label>
|
||||
</td>
|
||||
<td align="center">
|
||||
<label class="tutorial-font-small tutorial-skip-button"
|
||||
onclick="UI.projects.superalgos.spaces.tutorialSpace.skip()"
|
||||
onclick="UI.projects.education.spaces.tutorialSpace.skip()"
|
||||
value=""> Skip </label>
|
||||
</td>
|
||||
<td align="center">
|
||||
<label class="tutorial-font-small tutorial-previous-button"
|
||||
onclick="UI.projects.superalgos.spaces.tutorialSpace.previous()" value="">Previous</label>
|
||||
onclick="UI.projects.education.spaces.tutorialSpace.previous()" value="">Previous</label>
|
||||
</td>
|
||||
<td align="center">
|
||||
<label class="tutorial-font-small tutorial-next-button"
|
||||
onclick="UI.projects.superalgos.spaces.tutorialSpace.next()"
|
||||
onclick="UI.projects.education.spaces.tutorialSpace.next()"
|
||||
value=""> Next </label>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -102,98 +165,98 @@
|
||||
<div id="menu" class="docs-menu-table">
|
||||
<div class="menu-row">
|
||||
<div class="menu-item" onClick="window.contextMenu.editParagraph()">
|
||||
<img src="Icons/Superalgos/docs-action-edit-paragraph.png" class="menu-img" title="Edit">
|
||||
<img src="Icons/Foundations/Docs/docs-action-edit-paragraph.png" class="menu-img" title="Edit">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toTitle()">
|
||||
<img src="Icons/Superalgos/docs-title-style.png" class="menu-img" title="Title">
|
||||
<img src="Icons/Foundations/Docs/docs-title-style.png" class="menu-img" title="Title">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toSubtitle()">
|
||||
<img src="Icons/Superalgos/docs-subtitle-style.png" class="menu-img" title="Subtitle">
|
||||
<img src="Icons/Foundations/Docs/docs-subtitle-style.png" class="menu-img" title="Subtitle">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toNote()">
|
||||
<img src="Icons/Superalgos/docs-note-style.png" class="menu-img" title="Note">
|
||||
<img src="Icons/Foundations/Docs/docs-note-style.png" class="menu-img" title="Note">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toJavascript()">
|
||||
<img src="Icons/Superalgos/docs-js-code-style.png" class="menu-img" title="Javascript">
|
||||
<img src="Icons/Foundations/Docs/docs-js-code-style.png" class="menu-img" title="Javascript">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toYouTubeVideo()">
|
||||
<img src="Icons/Superalgos/docs-youtube-video-style.png" class="menu-img" title="Youtube">
|
||||
<img src="Icons/Foundations/Docs/docs-youtube-video-style.png" class="menu-img" title="Youtube">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toBlock()">
|
||||
<img src="Icons/Superalgos/docs-block-style.png" class="menu-img" title="Block">
|
||||
<img src="Icons/Foundations/Docs/docs-block-style.png" class="menu-img" title="Block">
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu-row">
|
||||
<div class="menu-item" onClick="window.contextMenu.copyLink()">
|
||||
<img src="Icons/Superalgos/docs-action-copy-to-clipboard.png" class="menu-img" title="Copy">
|
||||
<img src="Icons/Foundations/Docs/docs-action-copy-to-clipboard.png" class="menu-img" title="Copy">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toText()">
|
||||
<img src="Icons/Superalgos/docs-text-style.png" class="menu-img" title="Text">
|
||||
<img src="Icons/Foundations/Docs/docs-text-style.png" class="menu-img" title="Text">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toList()">
|
||||
<img src="Icons/Superalgos/docs-list-style.png" class="menu-img" title="List">
|
||||
<img src="Icons/Foundations/Docs/docs-list-style.png" class="menu-img" title="List">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toSuccess()">
|
||||
<img src="Icons/Superalgos/docs-success-style.png" class="menu-img" title="Success">
|
||||
<img src="Icons/Foundations/Docs/docs-success-style.png" class="menu-img" title="Success">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toJson()">
|
||||
<img src="Icons/Superalgos/docs-json-code-style.png" class="menu-img" title="Json">
|
||||
<img src="Icons/Foundations/Docs/docs-json-code-style.png" class="menu-img" title="Json">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toGif()">
|
||||
<img src="Icons/Superalgos/docs-gif-style.png" class="menu-img" title="Gif">
|
||||
<img src="Icons/Foundations/Docs/docs-gif-style.png" class="menu-img" title="Gif">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toInclude()">
|
||||
<img src="Icons/Superalgos/docs-include-style.png" class="menu-img" title="Include">
|
||||
<img src="Icons/Foundations/Docs/docs-include-style.png" class="menu-img" title="Include">
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu-row">
|
||||
<div class="menu-item" onClick="window.contextMenu.toPlaceholder()">
|
||||
<img src="Icons/Superalgos/docs-placeholder-style.png" class="menu-img" title="Placeholder">
|
||||
<img src="Icons/Foundations/Docs/docs-placeholder-style.png" class="menu-img" title="Placeholder">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toSummary()">
|
||||
<img src="Icons/Superalgos/docs-summary-style.png" class="menu-img" title="Summary">
|
||||
<img src="Icons/Foundations/Docs/docs-summary-style.png" class="menu-img" title="Summary">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toCallout()">
|
||||
<img src="Icons/Superalgos/docs-callout-style.png" class="menu-img" title="Callout">
|
||||
<img src="Icons/Foundations/Docs/docs-callout-style.png" class="menu-img" title="Callout">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toImportant()">
|
||||
<img src="Icons/Superalgos/docs-important-style.png" class="menu-img" title="Important">
|
||||
<img src="Icons/Foundations/Docs/docs-important-style.png" class="menu-img" title="Important">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toTable()">
|
||||
<img src="Icons/Superalgos/docs-table-style.png" class="menu-img" title="Table">
|
||||
<img src="Icons/Foundations/Docs/docs-table-style.png" class="menu-img" title="Table">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toPng()">
|
||||
<img src="Icons/Superalgos/docs-png-style.png" class="menu-img" title="Png">
|
||||
<img src="Icons/Foundations/Docs/docs-png-style.png" class="menu-img" title="Png">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toSection()">
|
||||
<img src="Icons/Superalgos/docs-section-style.png" class="menu-img" title="Section">
|
||||
<img src="Icons/Foundations/Docs/docs-section-style.png" class="menu-img" title="Section">
|
||||
</div>
|
||||
</div>
|
||||
<div class="menu-row">
|
||||
<div class="menu-item" onClick="window.contextMenu.deleteParagraph()">
|
||||
<img src="Icons/Superalgos/docs-action-delete-paragraph.png" class="menu-img" title="Delete">
|
||||
<img src="Icons/Foundations/Docs/docs-action-delete-paragraph.png" class="menu-img" title="Delete">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toWebPageLink()">
|
||||
<img src="Icons/Superalgos/docs-web-page-link-style.png" class="menu-img" title="Link">
|
||||
<img src="Icons/Foundations/Docs/docs-web-page-link-style.png" class="menu-img" title="Link">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toAnchor()">
|
||||
<img src="Icons/Superalgos/docs-anchor-style.png" class="menu-img" title="Anchor">
|
||||
<img src="Icons/Foundations/Docs/docs-anchor-style.png" class="menu-img" title="Anchor">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toWarning()">
|
||||
<img src="Icons/Superalgos/docs-warning-style.png" class="menu-img" title="Warning">
|
||||
<img src="Icons/Foundations/Docs/docs-warning-style.png" class="menu-img" title="Warning">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toHierarchy()">
|
||||
<img src="Icons/Superalgos/docs-hierarchy-style.png" class="menu-img" title="Hierarchy">
|
||||
<img src="Icons/Foundations/Docs/docs-hierarchy-style.png" class="menu-img" title="Hierarchy">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toError()">
|
||||
<img src="Icons/Superalgos/docs-error-style.png" class="menu-img" title="Error">
|
||||
<img src="Icons/Foundations/Docs/docs-error-style.png" class="menu-img" title="Error">
|
||||
</div>
|
||||
<div class="menu-item" onClick="window.contextMenu.toChapter()">
|
||||
<img src="Icons/Superalgos/docs-chapter-style.png" class="menu-img" title="Chapter">
|
||||
<img src="Icons/Foundations/Docs/docs-chapter-style.png" class="menu-img" title="Chapter">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
</html>
|
||||
+16
-12
@@ -6,7 +6,7 @@ global.env = ENVIRONMENT_MODULE
|
||||
|
||||
process.on('uncaughtException', function (err) {
|
||||
if (err.message && err.message.indexOf("EADDRINUSE") > 0) {
|
||||
console.log("A Superalgos Client cannot be started. Reason: the port " + port + " is already in use by another application.")
|
||||
console.log("A Superalgos Client cannot be started. Reason: the port configured migth be being used by another application.")
|
||||
return
|
||||
}
|
||||
console.log('[ERROR] Client -> client-> uncaughtException -> err.message = ' + err.message)
|
||||
@@ -16,6 +16,12 @@ process.on('uncaughtException', function (err) {
|
||||
})
|
||||
|
||||
process.on('unhandledRejection', (reason, p) => {
|
||||
// Signal user that a necissary node module is missing
|
||||
if (reason.code == 'MODULE_NOT_FOUND') {
|
||||
console.log("[ERROR] Node Modules not found. Running the node setup command and then restart")
|
||||
console.log('[ERROR] Client -> client-> reason = ' + JSON.stringify(reason))
|
||||
process.exit(1)
|
||||
}
|
||||
console.log('[ERROR] Client -> client-> unhandledRejection -> reason = ' + JSON.stringify(reason))
|
||||
console.log('[ERROR] Client -> client-> unhandledRejection -> p = ' + JSON.stringify(p))
|
||||
process.exit(1)
|
||||
@@ -127,21 +133,19 @@ try {
|
||||
console.log('Http Interface .............................................. Listening at port ' + global.env.HTTP_INTERFACE_PORT)
|
||||
|
||||
console.log('')
|
||||
console.log("You are running Superalgos Beta 10")
|
||||
console.log("You are running Superalgos Beta 11")
|
||||
console.log('')
|
||||
console.log("What's new? The following was implemented here:")
|
||||
console.log("What's new? These are the main new features in this version:")
|
||||
console.log('')
|
||||
console.log('Market Data Structure ....................................... This allows any strategy to use data from markets different from the one it is running at.')
|
||||
console.log('Exchange Data Structure ..................................... This allows any strategy to use data from exchanges and markets different from the one it is running at.')
|
||||
console.log('Tensor Flow Integration ..................................... This allows the creation and training of ML models that later can be used for predictions.')
|
||||
console.log('SA Token .................................................... This allows the project to compensate contributors that add value to it.')
|
||||
console.log('Governance System ........................................... Automates the distribution of SA Tokens and allow users to vote on the direction of the project.')
|
||||
console.log('TensorFlow Integration ...................................... Allows creating and training ML models and use them in trading strategies.')
|
||||
console.log('')
|
||||
console.log("What's next? At the development pipeline we have:")
|
||||
console.log("What's next? This is the current development pipeline:")
|
||||
console.log('')
|
||||
console.log('Contribution Management ..................................... This will allow us to manage contributions at scale, and distribute the SA token more efficiently at each release.')
|
||||
console.log('Infraestructure to sensor any API .......................... This will allow us to fetch data from any API, turn it into indicators and plot it.')
|
||||
console.log('Usage of ML Predictions at Trading Systems .................. This will enable a new kind of Bot that can learn from data mined. Later that knowledge can be used at trading strategies.')
|
||||
console.log('Ethereum Integration ........................................ This will allow mining data from an Ethereum network node, create indicators with it, an use it on strategies.')
|
||||
console.log('Superalgos P2P Network ...................................... Will allow algo-traders to share trading signals with Superalgos users consuming these signals via a mobile app.')
|
||||
console.log('Real-time Trading Signals ................................... Will allow users to emit trading signals and be rewarded with SA Tokens.')
|
||||
console.log('Superalgos Mobile ........................................... Will allow users to consume trading signals for free and autonomously execute trades from their mobile phones.')
|
||||
console.log('Ethereum Integration ........................................ Will allow mining data from an Ethereum network node, and bring it into the Superalgos workflow.')
|
||||
|
||||
console.log('')
|
||||
|
||||
|
||||
+547
-135
@@ -132,6 +132,25 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
respondWithContent(JSON.stringify(serverResponse), httpResponse)
|
||||
return
|
||||
}
|
||||
case 'signData': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.signData(
|
||||
params.privateKey,
|
||||
params.data
|
||||
)
|
||||
|
||||
respondWithContent(JSON.stringify(serverResponse), httpResponse)
|
||||
return
|
||||
}
|
||||
case 'recoverAddress': {
|
||||
|
||||
let serverResponse = await WEB3_SERVER.recoverAddress(
|
||||
params.signature
|
||||
)
|
||||
|
||||
respondWithContent(JSON.stringify(serverResponse), httpResponse)
|
||||
return
|
||||
}
|
||||
default: {
|
||||
respondWithContent(JSON.stringify({ error: 'Method ' + params.method + ' is invalid.' }), httpResponse)
|
||||
}
|
||||
@@ -505,40 +524,64 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
for (let i = 0; i < docsSchema.length; i++) {
|
||||
let schemaDocument = docsSchema[i]
|
||||
/*
|
||||
For some type of schemas we will save the file at an extra
|
||||
folder derived from the document's type.
|
||||
*/
|
||||
let fileName = schemaDocument.type.toLowerCase()
|
||||
for (let j = 0; j < 10; j++) {
|
||||
fileName = cleanFileName(fileName)
|
||||
}
|
||||
let pageNumber = '00' + schemaDocument.pageNumber
|
||||
|
||||
let newFilepath = filePath
|
||||
switch (category) {
|
||||
case 'Topic': {
|
||||
fileName = schemaDocument.topic.toLowerCase() + '-' + pageNumber.substring(pageNumber.length - 3, pageNumber.length) + '-' + schemaDocument.type.toLowerCase()
|
||||
fileName = cleanFileName(fileName)
|
||||
newFilepath = createPrefixDirectories(filePath, schemaDocument.topic)
|
||||
break
|
||||
}
|
||||
case 'Tutorial': {
|
||||
fileName = schemaDocument.tutorial.toLowerCase() + '-' + pageNumber.substring(pageNumber.length - 3, pageNumber.length) + '-' + schemaDocument.type.toLowerCase()
|
||||
fileName = cleanFileName(fileName)
|
||||
newFilepath = createPrefixDirectories(filePath, schemaDocument.tutorial)
|
||||
break
|
||||
}
|
||||
case 'Review': {
|
||||
fileName = schemaDocument.review.toLowerCase() + '-' + pageNumber.substring(pageNumber.length - 3, pageNumber.length) + '-' + schemaDocument.type.toLowerCase()
|
||||
fileName = cleanFileName(fileName)
|
||||
newFilepath = createPrefixDirectories(filePath, schemaDocument.review)
|
||||
break
|
||||
}
|
||||
case 'Node': {
|
||||
newFilepath = createPrefixDirectories(filePath, schemaDocument.type)
|
||||
break
|
||||
}
|
||||
case 'Concept': {
|
||||
newFilepath = createPrefixDirectories(filePath, schemaDocument.type)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function createPrefixDirectories(filePath, schemaTextToUse) {
|
||||
let firstLetter = schemaTextToUse.substring(0, 1)
|
||||
createNewDir(filePath + '/' + firstLetter)
|
||||
let extraWord = schemaTextToUse.split(' ')[0]
|
||||
createNewDir(filePath + '/' + firstLetter + '/' + extraWord)
|
||||
return filePath + '/' + firstLetter + '/' + extraWord + '/' + cleanFileName(schemaTextToUse)
|
||||
}
|
||||
|
||||
fileName = fileName + '.json'
|
||||
|
||||
if (schemaDocument.deleted === true) {
|
||||
try {
|
||||
fs.unlinkSync(filePath + '/' + fileName)
|
||||
console.log('[SUCCESS] ' + filePath + '/' + fileName + ' deleted.')
|
||||
fs.unlinkSync(newFilepath + '/' + fileName)
|
||||
console.log('[SUCCESS] ' + newFilepath + '/' + fileName + ' deleted.')
|
||||
} catch (err) {
|
||||
noErrorsDuringSaving = false
|
||||
console.log('[ERROR] httpInterface -> Docs -> Save -> ' + filePath + '/' + fileName + ' could not be deleted.')
|
||||
console.log('[ERROR] httpInterface -> Docs -> Save -> Resolve the issue that is preventing the Client to delete this file. Look at the error message below as a guide. At the UI you will need to delete this page again in order for the Client to retry next time you execute the docs.save command.')
|
||||
console.log('[ERROR] httpInterface -> Docs -> Save -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> Docs -> Delete -> ' + newFilepath + '/' + fileName + ' could not be deleted.')
|
||||
console.log('[ERROR] httpInterface -> Docs -> Delete -> Resolve the issue that is preventing the Client to delete this file. Look at the error message below as a guide. At the UI you will need to delete this page again in order for the Client to retry next time you execute the docs.save command.')
|
||||
console.log('[ERROR] httpInterface -> Docs -> Delete -> err.stack = ' + err.stack)
|
||||
}
|
||||
} else {
|
||||
if (schemaDocument.updated === true || schemaDocument.created === true) {
|
||||
@@ -548,28 +591,32 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
schemaDocument.updated = undefined
|
||||
schemaDocument.created = undefined
|
||||
let fileContent = JSON.stringify(schemaDocument, undefined, 4)
|
||||
try {
|
||||
fs.mkdirSync(filePath)
|
||||
} catch (err) {
|
||||
if (err.message.indexOf('file already exists') < 0) {
|
||||
throw (err)
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(filePath + '/' + fileName, fileContent)
|
||||
createNewDir(newFilepath)
|
||||
fs.writeFileSync(newFilepath + '/' + fileName, fileContent)
|
||||
if (created === true) {
|
||||
console.log('[SUCCESS] ' + filePath + '/' + fileName + ' created.')
|
||||
console.log('[SUCCESS] ' + newFilepath + '/' + fileName + ' created.')
|
||||
} else {
|
||||
if (updated === true) {
|
||||
console.log('[SUCCESS] ' + filePath + '/' + fileName + ' updated.')
|
||||
console.log('[SUCCESS] ' + newFilepath + '/' + fileName + ' updated.')
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
noErrorsDuringSaving = false
|
||||
console.log('[ERROR] httpInterface -> Docs -> Save -> ' + filePath + '/' + fileName + ' could not be created / updated.')
|
||||
console.log('[ERROR] httpInterface -> Docs -> Save -> ' + newFilepath + '/' + fileName + ' could not be created / updated.')
|
||||
console.log('[ERROR] httpInterface -> Docs -> Save -> err.stack = ' + err.stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function createNewDir(path) {
|
||||
try {
|
||||
fs.mkdirSync(path)
|
||||
} catch (err) {
|
||||
if (err.message.indexOf('file already exists') < 0) {
|
||||
throw (err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return noErrorsDuringSaving
|
||||
@@ -619,37 +666,43 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
contribute()
|
||||
|
||||
async function contribute() {
|
||||
await doGit()
|
||||
if (error !== undefined) {
|
||||
const { lookpath } = require('lookpath');
|
||||
const gitpath = await lookpath('git');
|
||||
if (gitpath === undefined) {
|
||||
console.log('[ERROR] `git` not installed.')
|
||||
} else {
|
||||
await doGit()
|
||||
if (error !== undefined) {
|
||||
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Contribution Not Sent',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Contribution Not Sent',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
return
|
||||
}
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
return
|
||||
}
|
||||
await doGithub()
|
||||
if (error !== undefined) {
|
||||
|
||||
await doGithub()
|
||||
if (error !== undefined) {
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Contribution Not Sent',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
console.log('respond with docs ')
|
||||
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Contribution Not Sent',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
respondWithDocsObject(docs, error)
|
||||
return
|
||||
}
|
||||
console.log('respond with docs ')
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
return
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
}
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
}
|
||||
|
||||
async function doGit() {
|
||||
@@ -681,7 +734,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: token,
|
||||
userAgent: 'Superalgos Beta 10'
|
||||
userAgent: 'Superalgos Beta 11'
|
||||
})
|
||||
|
||||
const repo = 'Superalgos'
|
||||
@@ -720,7 +773,8 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> commitMessage = ' + commitMessage)
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> username = ' + username)
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> token = ' + token)
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> token starts with = ' + token.substring(0, 10) + '...')
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> token ends with = ' + '...' + token.substring(token.length - 10))
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> currentBranch = ' + currentBranch)
|
||||
console.log('[ERROR] httpInterface -> App -> Contribute -> contributionsBranch = ' + contributionsBranch)
|
||||
|
||||
@@ -740,26 +794,32 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
update()
|
||||
|
||||
async function update() {
|
||||
let result = await doGit()
|
||||
|
||||
if (result.error === undefined) {
|
||||
let customResponse = {
|
||||
result: global.CUSTOM_OK_RESPONSE.result,
|
||||
message: result.message
|
||||
}
|
||||
respondWithContent(JSON.stringify(customResponse), httpResponse)
|
||||
const { lookpath } = require('lookpath');
|
||||
const gitpath = await lookpath('git');
|
||||
if (gitpath === undefined) {
|
||||
console.log('[ERROR] `git` not installed.')
|
||||
} else {
|
||||
let result = await doGit()
|
||||
|
||||
if (result.error === undefined) {
|
||||
let customResponse = {
|
||||
result: global.CUSTOM_OK_RESPONSE.result,
|
||||
message: result.message
|
||||
}
|
||||
respondWithContent(JSON.stringify(customResponse), httpResponse)
|
||||
} else {
|
||||
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Update Failed',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
respondWithDocsObject(docs, result.error)
|
||||
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Update Failed',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
respondWithDocsObject(docs, result.error)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -786,9 +846,6 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> commitMessage = ' + commitMessage)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> username = ' + username)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> token = ' + token)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
@@ -808,20 +865,26 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
checkout()
|
||||
|
||||
async function checkout() {
|
||||
await doGit()
|
||||
|
||||
if (error === undefined) {
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
const { lookpath } = require('lookpath');
|
||||
const gitpath = await lookpath('git');
|
||||
if (gitpath === undefined) {
|
||||
console.log('[ERROR] `git` not installed.')
|
||||
} else {
|
||||
let docs = {
|
||||
project: 'Superalgos',
|
||||
category: 'Topic',
|
||||
type: 'Switching Branches - Current Branch Not Changed',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
await doGit()
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
if (error === undefined) {
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
} else {
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'Switching Branches - Current Branch Not Changed',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -845,9 +908,68 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> commitMessage = ' + commitMessage)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> username = ' + username)
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> token = ' + token)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
case 'Branch': {
|
||||
try {
|
||||
branch()
|
||||
|
||||
async function branch() {
|
||||
const { lookpath } = require('lookpath');
|
||||
const gitpath = await lookpath('git');
|
||||
if (gitpath === undefined) {
|
||||
console.log('[ERROR] `git` not installed.')
|
||||
} else {
|
||||
let result = await doGit()
|
||||
|
||||
if (result.error === undefined) {
|
||||
let customResponse = {
|
||||
result: global.CUSTOM_OK_RESPONSE.result,
|
||||
message: result
|
||||
}
|
||||
respondWithContent(JSON.stringify(customResponse), httpResponse)
|
||||
} else {
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'App Error - Could Not Get Current Branch',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function doGit() {
|
||||
const simpleGit = require('simple-git');
|
||||
const options = {
|
||||
baseDir: process.cwd(),
|
||||
binary: 'git',
|
||||
maxConcurrentProcesses: 6,
|
||||
}
|
||||
const git = simpleGit(options)
|
||||
try {
|
||||
return await git.branch()
|
||||
} catch (err) {
|
||||
console.log('[ERROR] Error reading current branch.')
|
||||
console.log(err.stack)
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> App -> Update -> err.stack = ' + err.stack)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
@@ -897,6 +1019,176 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
break
|
||||
|
||||
case 'Gov': {
|
||||
switch (requestParameters[2]) { // switch by command
|
||||
case 'getGithubStars': {
|
||||
getProfiles('activity', 'listStargazersForRepo')
|
||||
break
|
||||
}
|
||||
case 'getGithubWatchers': {
|
||||
getProfiles('activity', 'listWatchersForRepo')
|
||||
break
|
||||
}
|
||||
case 'getGithubForks': {
|
||||
getProfiles('repos', 'listForks')
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function getProfiles(endpoint, method) {
|
||||
try {
|
||||
const GITHUB_API_WAITING_TIME = 250
|
||||
const repository = unescape(requestParameters[3])
|
||||
const username = unescape(requestParameters[4])
|
||||
const token = unescape(requestParameters[5])
|
||||
let error
|
||||
let githubListArray = []
|
||||
|
||||
getRepoInfo()
|
||||
|
||||
async function getRepoInfo() {
|
||||
await doGithub()
|
||||
if (error !== undefined) {
|
||||
|
||||
let docs = {
|
||||
project: 'Governance',
|
||||
category: 'Topic',
|
||||
type: 'Gov Error - Get Repository Information',
|
||||
anchor: undefined,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
respondWithDocsObject(docs, error)
|
||||
return
|
||||
}
|
||||
|
||||
respondWithContent(JSON.stringify(githubListArray), httpResponse)
|
||||
}
|
||||
|
||||
async function doGithub() {
|
||||
|
||||
const { Octokit } = require("@octokit/rest")
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: token,
|
||||
userAgent: 'Superalgos Beta 11'
|
||||
})
|
||||
await getList()
|
||||
|
||||
async function getList() {
|
||||
const repo = repository
|
||||
const owner = 'Superalgos'
|
||||
const per_page = 100 // Max
|
||||
let page = 0
|
||||
let lastPage = false
|
||||
|
||||
while (lastPage === false) {
|
||||
try {
|
||||
page++
|
||||
await sleep(GITHUB_API_WAITING_TIME)
|
||||
let listResponse = await octokit[endpoint][method]({
|
||||
owner,
|
||||
repo,
|
||||
per_page,
|
||||
page
|
||||
});
|
||||
|
||||
if (listResponse.data.length < 100) {
|
||||
lastPage = true
|
||||
}
|
||||
|
||||
for (let i = 0; i < listResponse.data.length; i++) {
|
||||
let listItem = listResponse.data[i]
|
||||
let githubUsername
|
||||
switch(endpoint) {
|
||||
case 'activity' : {
|
||||
githubUsername = listItem.login
|
||||
break
|
||||
}
|
||||
case 'repos' : {
|
||||
githubUsername = listItem.owner.login
|
||||
break
|
||||
}
|
||||
}
|
||||
//console.log(listItem)
|
||||
|
||||
githubListArray.push(githubUsername)
|
||||
}
|
||||
console.log('[INFO] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList -> ' + method + ' Page = ' + page)
|
||||
console.log('[INFO] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList -> ' + method + ' Received = ' + listResponse.data.length)
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
|
||||
if (err.stack.indexOf('last page') >= 0) {
|
||||
return
|
||||
} else {
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList ->Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList ->err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList ->repository = ' + repository)
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList ->username = ' + username)
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList ->token starts with = ' + token.substring(0, 10) + '...')
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> doGithub -> getList ->token ends with = ' + '...' + token.substring(token.length - 10))
|
||||
error = err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> repository = ' + repository)
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> username = ' + username)
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> token starts with = ' + token.substring(0, 10) + '...')
|
||||
console.log('[ERROR] httpInterface -> Gov -> getRepoInfo -> token ends with = ' + '...' + token.substring(token.length - 10))
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
}
|
||||
function respondWithDocsObject(docs, error) {
|
||||
|
||||
if (error.message !== undefined) {
|
||||
docs.placeholder.errorMessage = {
|
||||
style: 'Error',
|
||||
text: error.message
|
||||
}
|
||||
}
|
||||
if (error.stack !== undefined) {
|
||||
docs.placeholder.errorStack = {
|
||||
style: 'Javascript',
|
||||
text: error.stack
|
||||
}
|
||||
}
|
||||
if (error.code !== undefined) {
|
||||
docs.placeholder.errorCode = {
|
||||
style: 'Json',
|
||||
text: error.code
|
||||
}
|
||||
}
|
||||
|
||||
docs.placeholder.errorDetails = {
|
||||
style: 'Json',
|
||||
text: JSON.stringify(error, undefined, 4)
|
||||
}
|
||||
|
||||
let customResponse = {
|
||||
result: global.CUSTOM_FAIL_RESPONSE.result,
|
||||
docs: docs
|
||||
}
|
||||
|
||||
respondWithContent(JSON.stringify(customResponse), httpResponse)
|
||||
|
||||
}
|
||||
}
|
||||
break
|
||||
|
||||
case 'LegacyPlotter.js':
|
||||
{
|
||||
respondWithFile(global.env.PATH_TO_CLIENT + 'WebServer/LegacyPlotter.js', httpResponse)
|
||||
@@ -948,6 +1240,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
|
||||
path = unescape(path)
|
||||
|
||||
respondWithImage(path, httpResponse)
|
||||
}
|
||||
break
|
||||
@@ -1041,24 +1334,44 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
break
|
||||
|
||||
case 'ProjectNames':
|
||||
{
|
||||
let projects = getDirectories(global.env.PATH_TO_PROJECTS)
|
||||
respondWithContent(JSON.stringify(projects), httpResponse)
|
||||
}
|
||||
break
|
||||
|
||||
case 'Schema':
|
||||
{
|
||||
sendSchema(global.env.PATH_TO_PROJECTS + '/' + requestParameters[2] + '/Schemas/', requestParameters[3])
|
||||
}
|
||||
break
|
||||
|
||||
case 'DirContent':
|
||||
{
|
||||
let folderPath = unescape(requestParameters[2])
|
||||
if (requestParameters[3] !== undefined) {
|
||||
folderPath = folderPath + '/' + requestParameters[3]
|
||||
}
|
||||
|
||||
if (requestParameters[4] !== undefined) {
|
||||
folderPath = folderPath + '/' + requestParameters[4]
|
||||
}
|
||||
|
||||
if (requestParameters[5] !== undefined) {
|
||||
folderPath = folderPath + '/' + requestParameters[5]
|
||||
}
|
||||
let folder
|
||||
if (requestParameters[2] === 'Root') {
|
||||
folder = folderPath.replace('Root', '../Superalgos/')
|
||||
} else {
|
||||
folder = global.env.PATH_TO_PROJECTS + '/' + folderPath
|
||||
}
|
||||
|
||||
getAllFilesInDirectoryAndSubdirectories(folder, onFilesReady)
|
||||
|
||||
function onFilesReady(files) {
|
||||
respondWithContent(JSON.stringify(files), httpResponse)
|
||||
}
|
||||
}
|
||||
break
|
||||
|
||||
case 'IconNames':
|
||||
{
|
||||
let projects = getDirectories(global.env.PATH_TO_PROJECTS)
|
||||
const fs = require('fs')
|
||||
|
||||
let icons = []
|
||||
let totalProjects = projects.length
|
||||
let projectCounter = 0
|
||||
@@ -1068,9 +1381,14 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
const folder = global.env.PATH_TO_PROJECTS + '/' + project + '/Icons/'
|
||||
|
||||
fs.readdir(folder, (err, files) => {
|
||||
getAllFilesInDirectoryAndSubdirectories(folder, onFilesReady)
|
||||
|
||||
function onFilesReady(files) {
|
||||
for (let j = 0; j < files.length; j++) {
|
||||
let file = files[j]
|
||||
for (let i = 0; i < 10; i++) {
|
||||
file = file.replace('/', '\\')
|
||||
}
|
||||
icons.push([project, file])
|
||||
}
|
||||
|
||||
@@ -1078,7 +1396,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
if (projectCounter === totalProjects) {
|
||||
respondWithContent(JSON.stringify(icons), httpResponse)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
@@ -1092,6 +1410,9 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
let folder = global.env.PATH_TO_PROJECTS + '/' + project + '/Plugins/' + pluginType
|
||||
|
||||
fs.readdir(folder, (err, files) => {
|
||||
if (files === undefined) {
|
||||
files = []
|
||||
}
|
||||
respondWithContent(JSON.stringify(files), httpResponse)
|
||||
})
|
||||
}
|
||||
@@ -1107,6 +1428,35 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
break
|
||||
|
||||
case 'SavePlugin':
|
||||
getBody(processRequest)
|
||||
|
||||
async function processRequest(body) {
|
||||
try {
|
||||
let plugin = JSON.parse(body)
|
||||
let project = requestParameters[2]
|
||||
let folder = requestParameters[3]
|
||||
let fileName = requestParameters[4]
|
||||
let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Plugins/' + folder
|
||||
let fileContent = JSON.stringify(plugin, undefined, 4)
|
||||
const fs = require('fs')
|
||||
fs.writeFileSync(filePath + '/' + fileName + '.json', fileContent)
|
||||
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> SavePlugin -> Method call produced an error.')
|
||||
console.log('[ERROR] httpInterface -> SavePlugin -> err.stack = ' + err.stack)
|
||||
console.log('[ERROR] httpInterface -> SavePlugin -> Params Received = ' + body)
|
||||
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
message: err.message,
|
||||
stack: err.stack
|
||||
}
|
||||
respondWithContent(JSON.stringify(error), httpResponse)
|
||||
}
|
||||
}
|
||||
break
|
||||
|
||||
case 'Workspace.js':
|
||||
{
|
||||
let fs = require('fs')
|
||||
@@ -1237,7 +1587,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
function onFileWritten(err) {
|
||||
if (err) {
|
||||
console.log('[ERROR] SaveWorkspace -> onFileWritten -> Error writting the Workspace file. fileName = ' + fileName)
|
||||
console.log('[ERROR] SaveWorkspace -> onFileWritten -> Error writing the Workspace file. fileName = ' + fileName)
|
||||
console.log('[ERROR] SaveWorkspace -> onFileWritten -> err.stack = ' + err.stack)
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
@@ -1251,7 +1601,7 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log('[ERROR] SaveWorkspace -> Error writting the Workspace file. fileName = ' + fileName)
|
||||
console.log('[ERROR] SaveWorkspace -> Error writing the Workspace file. fileName = ' + fileName)
|
||||
console.log('[ERROR] SaveWorkspace -> err.stack = ' + err.stack)
|
||||
let error = {
|
||||
result: 'Fail Because',
|
||||
@@ -1392,6 +1742,12 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
}
|
||||
break
|
||||
|
||||
case 'governance.css':
|
||||
{
|
||||
sendStyleSheet('governance.css')
|
||||
}
|
||||
break
|
||||
|
||||
case 'context-menu.css':
|
||||
{
|
||||
sendStyleSheet('context-menu.css')
|
||||
@@ -1496,57 +1852,73 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
|
||||
function sendSchema(filePath, schemaType) {
|
||||
let fs = require('fs')
|
||||
try {
|
||||
let folder = ''
|
||||
switch (schemaType) {
|
||||
case 'AppSchema': {
|
||||
folder = 'App-Schema'
|
||||
break
|
||||
}
|
||||
case 'DocsNodeSchema': {
|
||||
folder = 'Docs-Nodes'
|
||||
break
|
||||
}
|
||||
case 'DocsConceptSchema': {
|
||||
folder = 'Docs-Concepts'
|
||||
break
|
||||
}
|
||||
case 'DocsTopicSchema': {
|
||||
folder = 'Docs-Topics'
|
||||
break
|
||||
}
|
||||
case 'DocsTutorialSchema': {
|
||||
folder = 'Docs-Tutorials'
|
||||
break
|
||||
}
|
||||
case 'DocsReviewSchema': {
|
||||
folder = 'Docs-Reviews'
|
||||
break
|
||||
}
|
||||
case 'DocsBookSchema': {
|
||||
folder = 'Docs-Books'
|
||||
break
|
||||
}
|
||||
try {
|
||||
let folder = ''
|
||||
switch (schemaType) {
|
||||
case 'AppSchema': {
|
||||
folder = 'App-Schema'
|
||||
break
|
||||
}
|
||||
case 'DocsNodeSchema': {
|
||||
folder = 'Docs-Nodes'
|
||||
break
|
||||
}
|
||||
case 'DocsConceptSchema': {
|
||||
folder = 'Docs-Concepts'
|
||||
break
|
||||
}
|
||||
case 'DocsTopicSchema': {
|
||||
folder = 'Docs-Topics'
|
||||
break
|
||||
}
|
||||
case 'DocsTutorialSchema': {
|
||||
folder = 'Docs-Tutorials'
|
||||
break
|
||||
}
|
||||
case 'DocsReviewSchema': {
|
||||
folder = 'Docs-Reviews'
|
||||
break
|
||||
}
|
||||
case 'DocsBookSchema': {
|
||||
folder = 'Docs-Books'
|
||||
break
|
||||
}
|
||||
}
|
||||
getAllFilesInDirectoryAndSubdirectories(filePath + folder, onFilesReady)
|
||||
function onFilesReady(files) {
|
||||
|
||||
let schemaArray = []
|
||||
let fileList = fs.readdirSync(filePath + '/' + folder)
|
||||
for (let k = 0; k < fileList.length; k++) {
|
||||
let name = fileList[k]
|
||||
let fileContent = fs.readFileSync(filePath + '/' + folder + '/' + name)
|
||||
let schemaDocument = JSON.parse(fileContent)
|
||||
for (let k = 0; k < files.length; k++) {
|
||||
let name = files[k]
|
||||
let nameSplitted = name.split(folder)
|
||||
let fileName = nameSplitted[1]
|
||||
for (let i = 0; i < 10; i++) {
|
||||
fileName = fileName.replace('\\', '/')
|
||||
}
|
||||
let fileToRead = filePath + folder + fileName
|
||||
|
||||
let fileContent = fs.readFileSync(fileToRead)
|
||||
let schemaDocument
|
||||
try {
|
||||
schemaDocument = JSON.parse(fileContent)
|
||||
} catch (err) {
|
||||
console.log('[ERROR] httpInterface -> sendSchema -> Error Parsing JSON File: ' + fileToRead + ' .Error = ' + err.stack)
|
||||
respondWithContent("[]", httpResponse)
|
||||
return
|
||||
}
|
||||
schemaArray.push(schemaDocument)
|
||||
}
|
||||
let schema = JSON.stringify(schemaArray)
|
||||
respondWithContent(schema, httpResponse)
|
||||
} catch (err) {
|
||||
if (err.message.indexOf('no such file or directory') < 0) {
|
||||
console.log('Could not send Schema:', filePath, schemaType)
|
||||
console.log(err.stack)
|
||||
}
|
||||
respondWithContent("[]", httpResponse)
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
if (err.message.indexOf('no such file or directory') < 0) {
|
||||
console.log('Could not send Schema:', filePath, schemaType)
|
||||
console.log(err.stack)
|
||||
}
|
||||
respondWithContent("[]", httpResponse)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function sendStyleSheet(fileName) {
|
||||
@@ -1727,4 +2099,44 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
|
||||
return []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getAllFilesInDirectoryAndSubdirectories(dir, callback) {
|
||||
const { promisify } = require('util');
|
||||
const { resolve } = require('path');
|
||||
const fs = require('fs');
|
||||
const readdir = promisify(fs.readdir);
|
||||
const stat = promisify(fs.stat);
|
||||
|
||||
getFiles(dir)
|
||||
.then(files => {
|
||||
let splittedDir = dir.split('/')
|
||||
let lastFolder = splittedDir[splittedDir.length - 2]
|
||||
let pathAndNames = []
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
let file = files[i]
|
||||
let pathName = file.substring(file.indexOf(lastFolder) + lastFolder.length, file.length)
|
||||
pathName = pathName.substring(1, pathName.length)
|
||||
pathAndNames.push(pathName)
|
||||
}
|
||||
callback(pathAndNames)
|
||||
})
|
||||
.catch(e => {
|
||||
callback([])
|
||||
});
|
||||
|
||||
async function getFiles(dir) {
|
||||
const subdirs = await readdir(dir);
|
||||
const files = await Promise.all(subdirs.map(async (subdir) => {
|
||||
const res = resolve(dir, subdir);
|
||||
return (await stat(res)).isDirectory() ? getFiles(res) : res;
|
||||
}));
|
||||
return files.reduce((a, f) => a.concat(f), []);
|
||||
}
|
||||
}
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, ms)
|
||||
})
|
||||
}
|
||||
}
|
||||
Generated
+3946
-100
File diff suppressed because it is too large.
Load diff
+2
-1
@@ -8,8 +8,9 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/rest": "^18.0.12",
|
||||
"ccxt": "^1.51.61",
|
||||
"ccxt": "^1.51.98",
|
||||
"child_process": "^1.0.2",
|
||||
"lookpath": "^1.2.1",
|
||||
"open": "^6.4.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"simple-git": "^2.31.0",
|
||||
|
||||
+45
-11
@@ -6,6 +6,8 @@ exports.newWeb3Server = function newWeb3Server() {
|
||||
getNetworkClientStatus: getNetworkClientStatus,
|
||||
createWalletAccount: createWalletAccount,
|
||||
getWalletBalances: getWalletBalances,
|
||||
signData: signData,
|
||||
recoverAddress: recoverAddress,
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
run: run
|
||||
@@ -56,7 +58,7 @@ exports.newWeb3Server = function newWeb3Server() {
|
||||
return status
|
||||
}
|
||||
} catch (err) {
|
||||
return { error: 'Could not connect to ' + key + '. ' + err.message + '.' }
|
||||
return { error: 'Could not connect to ' + key + '. ' + err.stack + '.' }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,7 +75,7 @@ exports.newWeb3Server = function newWeb3Server() {
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
return { error: 'Could not create the account. ' + err.message }
|
||||
return { error: 'Could not create the account. ' + err.stack }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,22 +118,22 @@ exports.newWeb3Server = function newWeb3Server() {
|
||||
for (let j = 0; j < walletAccount.tokenBalances.length; j++) {
|
||||
let tokenBalance = walletAccount.tokenBalances[j]
|
||||
|
||||
if (tokenBalance.referenceParent === undefined) { continue }
|
||||
if (tokenBalance.referenceParent.parentNode === undefined) { continue }
|
||||
if (tokenBalance.referenceParent.smartContracts === undefined) { continue }
|
||||
if (tokenBalance.referenceParent === undefined) { continue }
|
||||
if (tokenBalance.referenceParent.parentNode === undefined) { continue }
|
||||
if (tokenBalance.referenceParent.smartContracts === undefined) { continue }
|
||||
|
||||
if (tokenBalance.referenceParent.config.codeName === undefined) {
|
||||
tokenBalance.error = 'Reference Parent without config.codeName defined.'
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if (tokenBalance.referenceParent.smartContracts.config.address === undefined) {
|
||||
tokenBalance.error = 'Reference Parent Smart Contract without config.address defined.'
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
let tokenContractAddress = tokenBalance.referenceParent.smartContracts.config.address
|
||||
// The minimum ABI to get ERC20 Token balance
|
||||
// The minimum ABI to get ERC20 Token balance
|
||||
let minABI = [
|
||||
// balanceOf
|
||||
{
|
||||
@@ -152,8 +154,8 @@ exports.newWeb3Server = function newWeb3Server() {
|
||||
];
|
||||
|
||||
let contract = new web3.eth.Contract(minABI, tokenContractAddress);
|
||||
|
||||
try {
|
||||
|
||||
try {
|
||||
tokenBalance.value = await contract.methods.balanceOf(walletAccount.config.address).call()
|
||||
} catch (err) {
|
||||
if (err.message.indexOf('Provided address') >= 0) {
|
||||
@@ -170,7 +172,7 @@ exports.newWeb3Server = function newWeb3Server() {
|
||||
return responseData
|
||||
}
|
||||
} catch (err) {
|
||||
return { error: 'Could not connect to ' + key + '. ' + err.message + '.' }
|
||||
return { error: 'Could not connect to ' + key + '. ' + err.stack + '.' }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,4 +204,36 @@ exports.newWeb3Server = function newWeb3Server() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function signData(privateKey, data) {
|
||||
try {
|
||||
|
||||
let web3 = new Web3()
|
||||
let signature = web3.eth.accounts.sign(data, privateKey)
|
||||
|
||||
return {
|
||||
signature: signature,
|
||||
result: 'Ok'
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
return { error: 'Could not sign the data. ' + err.stack }
|
||||
}
|
||||
}
|
||||
|
||||
async function recoverAddress(signature) {
|
||||
try {
|
||||
let signatureObject = JSON.parse(signature)
|
||||
let web3 = new Web3()
|
||||
let address = web3.eth.accounts.recover(signatureObject)
|
||||
|
||||
return {
|
||||
address: address,
|
||||
result: 'Ok'
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
return { error: 'Could not recover address. ' + err.stack }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user