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

This commit is contained in:
harrellbm committed 2021-11-02 10:39:53 -05:00
commit ed1814d40d
11 files changed
+74281 -55527

No files matched your search

+5 -3
View File
@@ -1,6 +1,8 @@
Data-Storage
Log-Files
My-Workspaces
**/Data-Storage
**/My-Data-Storage
**/Log-Files
**/My-Log-Files
**/My-Workspaces
debug.log
*.db
+1 -1
View File
@@ -642,7 +642,7 @@ exports.newHttpInterface = function newHttpInterface() {
{
// If running the electron app do not try to get git tool. I don't allow it.
if (process.env.SA_MODE === 'gitDisable') {
console.log('[WARNING] No contributions on binary distributions. Do manual installation')
console.log('[WARN] No contributions on binary distributions. Do manual installation')
break
}
switch (requestPath[2]) { // switch by command
+5 -3
View File
@@ -290,7 +290,7 @@ exports.newWeb3Server = function newWeb3Server() {
console.log('----------------------------------------------------------------------------------------------')
for (let i = 0; i < paymentsArray.length; i++) {
await PL.projects.foundations.utilities.asyncFunctions.sleep(10000)
await PL.projects.foundations.utilities.asyncFunctions.sleep(15000)
let payment = paymentsArray[i]
await sendTokens(
i + 1,
@@ -360,11 +360,13 @@ exports.newWeb3Server = function newWeb3Server() {
transaction.sign(privateKeyBuffer)
console.log('Transaction:', rawTransaction)
const result = await web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex'))
let result
result = await web3.eth.sendSignedTransaction('0x' + transaction.serialize().toString('hex'))
.catch(err => {
console.log('[ERROR] sendSignedTransaction -> err =' + JSON.stringify(err))
})
console.log('Result:', result)
return result
} catch (err) {
@@ -451,9 +451,16 @@ exports.newFileStorage = function newFileStorage(processIndex, host, port) {
function getFileViaHTTP(filePath, callback, callBackFunction) {
try {
/* The filePath received is the one that is needed to fetch data from with fs. To do it via http we need to remove the prefix that includes this: ./Data-Storage/ */
filePath = filePath.substring(15, filePath.length)
/*
The filePath received is the one that is needed to fetch data from with fs. To do it via http we need to remove the
prefix that includes this: ./Data-Storage/
*/
let pathArray = filePath.split('/')
let indexmax = pathArray.indexOf('My-Data-Storage') // TODO: get rid of hardcoded path name
for (var i = 0; i <= indexmax; i++) {
pathArray.shift()
}
filePath = pathArray.join('/')
let http = SA.nodeModules.http
let url = 'http://' + host +
@@ -506,4 +513,4 @@ exports.newFileStorage = function newFileStorage(processIndex, host, port) {
callBackFunction(TS.projects.foundations.globals.standardResponses.DEFAULT_RETRY_RESPONSE);
}
}
}
}
File diff suppressed because it is too large. Load diff
@@ -15,7 +15,7 @@ function newGovernanceUserProfileSpace() {
}
let waitingForResponses = 0
const BSC_SCAN_RATE_LIMIT_DELAY = 10000 * 6
const BSC_SCAN_RATE_LIMIT_DELAY = 6000 * 6
let reputationByAddress = new Map()
return thisObject
@@ -452,16 +452,16 @@ function newGovernanceUserProfileSpace() {
waitingForResponses++
waitingForResponses++
waitingForResponses++
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 5 * 1, userProfile, blockchainAccount, 'BTCB', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BTCB_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 5 * 2, userProfile, blockchainAccount, 'BNB', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BNB_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 5 * 3, userProfile, blockchainAccount, 'BUSD', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BUSD_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 5 * 4, userProfile, blockchainAccount, 'ETH', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_ETH_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 6 * 1, userProfile, blockchainAccount, 'BTCB', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BTCB_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 6 * 2, userProfile, blockchainAccount, 'BNB', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BNB_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 6 * 3, userProfile, blockchainAccount, 'BUSD', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_BUSD_CONTRACT_ADDRESS)
setTimeout(getBPancakeTokens, BSC_SCAN_RATE_LIMIT_DELAY / 6 * 4, userProfile, blockchainAccount, 'ETH', UI.projects.governance.globals.saToken.SA_TOKEN_BSC_PANCAKE_LIQUIDITY_POOL_ETH_CONTRACT_ADDRESS)
/*
Now we get the SA Tokens Balance.
*/
waitingForResponses++
setTimeout(getBlockchainTokens, BSC_SCAN_RATE_LIMIT_DELAY / 5 * 5, userProfile, blockchainAccount)
setTimeout(getBlockchainTokens, BSC_SCAN_RATE_LIMIT_DELAY / 6 * 5, userProfile, blockchainAccount)
}
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+98
View File
@@ -0,0 +1,98 @@
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8"/>
<title>Console Logs</title>
<style>
/* #log-container { overflow: auto; } */
.log-warn { color: orange }
.log-error { color: red }
.log-info { color: skyblue }
.log-log { color: silver }
.log-warn, .log-error { font-weight: bold; }
</style>
</head>
<body>
<div id="log-container">
<pre id="log"></pre>
</div>
<script>
window.onload = () => {
window.api.receive('fromMain', (data) => {
//const consoleLine = document.createElement('span')
//const consoleLineText = document.createTextNode(data)
//consoleLine.appendChild(consoleLineText)
if(data.includes('[ERROR]')) {
//const consoleLine = document.createElement('span')
document.getElementById('log').insertAdjacentHTML('beforeend', "<span class=\"log-error\">" + data + "</span><br>");
}
if(data.includes('[WARN]')) {
//consoleLineText.style.cssText = "color: orange; font-weight: bold;"
document.getElementById('log').insertAdjacentHTML('beforeend',"<span class=\"log-warn\">" + data + "</span><br>");
}
document.getElementById('log').insertAdjacentHTML('beforeend',"<span class=\"log-info\">" + data + "</span><br>");
//document.getElementById('log').insertAdjacentHTML('beforeend', consoleLineText);
})
window.api.send("toMain", "ImAlive!")
}
</script>
<!-- <script>
rewireLoggingToElement(
() => document.getElementById("log"),
() => document.getElementById("log-container"), true);
function rewireLoggingToElement(eleLocator, eleOverflowLocator, autoScroll) {
fixLoggingFunc('log');
fixLoggingFunc('debug');
fixLoggingFunc('warn');
fixLoggingFunc('error');
fixLoggingFunc('info');
function fixLoggingFunc(name) {
console['old' + name] = console[name];
console[name] = function(...arguments) {
//const output = produceOutput(name, arguments);
output = window.api.receive('fromMain', (message, arguments) => {
produceOutput(message, arguments)
})
const eleLog = eleLocator();
if (autoScroll) {
const eleContainerLog = eleOverflowLocator();
const isScrolledToBottom = eleContainerLog.scrollHeight - eleContainerLog.clientHeight <= eleContainerLog.scrollTop + 1;
eleLog.innerHTML += output + "<br>";
if (isScrolledToBottom) {
eleContainerLog.scrollTop = eleContainerLog.scrollHeight - eleContainerLog.clientHeight;
}
} else {
eleLog.innerHTML += output + "<br>";
}
console['old' + name].apply(undefined, arguments);
};
}
function produceOutput(name, args) {
return args.reduce((output, arg) => {
return output +
"<span class=\"log-" + (typeof arg) + " log-" + name + "\">" +
(typeof arg === "object" && (JSON || {}).stringify ? JSON.stringify(arg) : arg) +
"</span>&nbsp;";
}, '');
}
}
/* setInterval(() => {
const method = (['log', 'debug', 'warn', 'error', 'info'][Math.floor(Math.random() * 5)]);
console[method](method, 'logging something...');
}, 200); */
</script> -->
</body>
</html>
+123 -16
View File
@@ -1,9 +1,10 @@
const {app, Menu, BrowserWindow} = require('electron')
const {app, Menu, BrowserWindow, ipcMain} = require('electron')
const path = require('path')
const fs = require('fs')
// To check for update on Github repo
const {autoUpdater} = require("electron-updater")
const { windowsStore } = require('process')
// Enable non contribution mode (test)
process.env.SA_MODE = 'gitDisable'
@@ -13,7 +14,7 @@ process.env.DATA_PATH = app.getPath('documents')
const WINDOW_WIDTH = null
const WINDOW_HEIGHT = null
var w
let mainWindow, consoleWindow, platform
var app_ready = false
var server_ready = false
@@ -22,42 +23,100 @@ const port = 34248 // Default HTTP port
run()
//var platform = null
function run() {
const { fork } = require('child_process')
const platform = fork(path.join(__dirname, '/PlatformRoot.js'), ["noBrowser"], {stdio: ['pipe', 'pipe', 'pipe', 'ipc'], env: process.env})
platform.on('message', message => {
if(message == "Running") {
open()
}
platform = fork(path.join(__dirname, '/PlatformRoot.js'), ["noBrowser"], {stdio: ['pipe', 'pipe', 'pipe', 'ipc'], env: process.env})
//var consoleOutput = ""
platform.on('message', _ => {
open()
})
}
ipcMain.on("toMain", (event, args) => {
platform.stdout.setEncoding('utf8')
platform.stdout.on('data', (data) => {
//data = data.toString()
//consoleOutput += data
consoleWindow.webContents.send("fromMain", data);
})
})
function open () {
let bw_options = {
width: WINDOW_WIDTH ? WINDOW_WIDTH : 1280,
height: WINDOW_HEIGHT ? WINDOW_HEIGHT : 768,
resizable: true
resizable: true,
webPreferences: {
nodeIntegration: false, // is default value after Electron v5
contextIsolation: true, // protect against prototype pollution
enableRemoteModule: false, // turn off remote
}
}
w = new BrowserWindow(
mainWindow = new BrowserWindow(
bw_options
)
w.setResizable(true)
//mainWindow.setResizable(true)
w.loadURL("http://localhost:" + port)
mainWindow.loadURL("http://localhost:" + port)
// w.webContents.openDevTools()
w.on('closed', function () {
w = null
mainWindow.on('closed', function () {
mainWindow = null
})
}
function openConsoleWindow() {
createConsoleMenus()
if(consoleWindow) {
consoleWindow.focus()
return
}
newWindow =
consoleWindow = new BrowserWindow({
resizable: true,
title: 'Platform Logs',
minimizable: false,
fullscreenable: false,
width: 1024,
webPreferences: {
devTools: true,
nodeIntegration: false, // is default value after Electron v5
contextIsolation: true, // protect against prototype pollution
enableRemoteModule: false, // turn off remote
preload: path.join(__dirname, "preload.js") // use a preload script
}
})
consoleWindow.setBackgroundColor('#000000')
consoleWindow.loadFile('./console.html')
/* consoleWindow.on('ready'), _ => {
platform.stdout.setEncoding('utf8')
platform.stdout.on('data', (data) => {
//data = data.toString()
//consoleOutput += data
consoleWindow.webContents.send("fromMain", data);
})
} */
consoleWindow.on('closed', function() {
consoleWindow = null
})
}
app.on('ready', function () {
app_ready = true
autoUpdater.checkForUpdatesAndNotify();
create_menus()
createMainMenus()
if (server_ready) open()
})
@@ -69,7 +128,7 @@ app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
function create_menus () {
function createMainMenus () {
const template = [
{
label: 'File',
@@ -88,7 +147,6 @@ function create_menus () {
{role: 'cut'},
{role: 'copy'},
{role: 'paste'},
{role: 'pasteandmatchstyle'},
{role: 'delete'},
{role: 'selectall'}
]
@@ -115,6 +173,55 @@ function create_menus () {
{type: 'separator'},
{role: 'togglefullscreen'}
]
},
{
label: 'Logs',
click () {
openConsoleWindow()
}
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
}
function createConsoleMenus () {
const template = [
{
label: 'File',
submenu: [
{
role: 'quit'
}
]
},
{
label: 'Edit',
submenu: [
{role: 'undo'},
{role: 'redo'},
{type: 'separator'},
{role: 'cut'},
{role: 'copy'},
{role: 'paste'},
{role: 'delete'},
{role: 'selectall'}
]
},
{
label: 'View',
submenu: [
{role: 'reload'},
{role: 'forcereload'},
{role: 'toggledevtools'},
{type: 'separator'},
{role: 'resetzoom'},
{role: 'zoomin'},
{role: 'zoomout'},
{type: 'separator'},
{role: 'togglefullscreen'}
]
}
]
+25
View File
@@ -0,0 +1,25 @@
const {
contextBridge,
ipcRenderer
} = require("electron");
// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld(
"api", {
send: (channel, data) => {
// whitelist channels
let validChannels = ["toMain"];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, func) => {
let validChannels = ["fromMain"];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
}
}
);