axios working
This commit is contained in:
1 parent
a90c8256ac
commit
28216a08d0
6 files changed
+229
-27918
No files matched your search
+1
-1
@@ -154,7 +154,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
/* Initialize this */
|
||||
tradingEngine.tradingCurrent.tradingEpisode.distanceToTradingEvent.triggerOn.value = 1
|
||||
|
||||
outgoingTradingSignalsModuleObject.broadcastSignal(triggerStage.triggerOn)
|
||||
await outgoingTradingSignalsModuleObject.broadcastSignal(triggerStage.triggerOn)
|
||||
announcementsModuleObject.makeAnnouncements(triggerStage.triggerOn)
|
||||
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.type === 'Backtesting Session') {
|
||||
|
||||
@@ -29,10 +29,10 @@ exports.newNetworkModulesHttpInterface = function newNetworkModulesHttpInterface
|
||||
let endpointOrFile = requestPath[1]
|
||||
|
||||
switch (endpointOrFile) {
|
||||
case 'Signal':
|
||||
case 'New-Signal':
|
||||
{
|
||||
let message = requestPath[2]
|
||||
let response = await thisObject.clientInterface.messageReceived(message)
|
||||
let response = 'Message Received' //await thisObject.clientInterface.messageReceived(message)
|
||||
SA.projects.foundations.utilities.httpResponses.respondWithContent(JSON.stringify(response), httpResponse)
|
||||
}
|
||||
break
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
exports.newNetworkModulesHttpNetworkClient = function newNetworkModulesHttpNetworkClient() {
|
||||
|
||||
let thisObject = {
|
||||
callerRole: undefined,
|
||||
callerRole: undefined,
|
||||
host: undefined,
|
||||
port: undefined,
|
||||
p2pNetworkNode: undefined,
|
||||
@@ -38,31 +38,151 @@ exports.newNetworkModulesHttpNetworkClient = function newNetworkModulesHttpNetwo
|
||||
thisObject.port = JSON.parse(thisObject.p2pNetworkNode.node.config).webPort
|
||||
}
|
||||
|
||||
function sendMessage(message) {
|
||||
return new Promise(sendHttpMessage)
|
||||
async function sendMessage(message) {
|
||||
|
||||
async function sendHttpMessage(resolve, reject) {
|
||||
try {
|
||||
let signature = web3.eth.accounts.sign(JSON.stringify(message), SA.secrets.map.get(thisObject.p2pNetworkClientCodeName).privateKey)
|
||||
await axios()
|
||||
async function axios() {
|
||||
/*
|
||||
This function helps a caller to use await syntax while the called
|
||||
function uses callbacks, specifically for retrieving files.
|
||||
*/
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
|
||||
let body = {
|
||||
messageId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
|
||||
messageType: 'Request',
|
||||
signature: JSON.stringify(signature),
|
||||
payload: JSON.stringify(message)
|
||||
}
|
||||
const fetch = SA.nodeModules.nodeFetch
|
||||
const response = await fetch('https://' + thisObject.host + ':' + thisObject.port + '/' + 'New-Signal', {
|
||||
method: 'post',
|
||||
body: JSON.stringify(body),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
});
|
||||
const data = await response.json();
|
||||
resolve(data)
|
||||
} catch (err) {
|
||||
console.log('[ERROR] Http Network Client -> err.message = ' + err.message)
|
||||
reject(err.description)
|
||||
const axios = require('axios')
|
||||
console.log('call axios')
|
||||
axios
|
||||
.post('http://localhost:31248/New-Signal', {
|
||||
messageId: 'La concha de tu madre.'
|
||||
})
|
||||
.then(res => {
|
||||
console.log(`statusCode: ${res.status}`)
|
||||
console.log('ATENTIONNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN !!!!!!!!!!!!!!!! ' + res.data)
|
||||
resolve()
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error)
|
||||
reject()
|
||||
})
|
||||
})
|
||||
|
||||
return promise
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
let signature = web3.eth.accounts.sign(JSON.stringify(message), SA.secrets.map.get(thisObject.p2pNetworkClientCodeName).privateKey)
|
||||
|
||||
let body = {
|
||||
messageId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
|
||||
messageType: 'Request',
|
||||
signature: JSON.stringify(signature),
|
||||
payload: JSON.stringify(message)
|
||||
}
|
||||
|
||||
const data = JSON.stringify(body)
|
||||
const http = SA.nodeModules.http
|
||||
|
||||
const options = {
|
||||
hostname: thisObject.host,
|
||||
port: thisObject.port,
|
||||
path: '/New-Signal',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': data.length
|
||||
}
|
||||
}
|
||||
|
||||
const req = http.request(options, res => {
|
||||
console.log(`statusCode: ${res.statusCode}`)
|
||||
|
||||
res.on('data', d => {
|
||||
process.stdout.write(d)
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', error => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.write(data)
|
||||
req.end()
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
return new Promise(sendHttpMessage)
|
||||
|
||||
async function sendHttpMessage(resolve, reject) {
|
||||
try {
|
||||
let signature = web3.eth.accounts.sign(JSON.stringify(message), SA.secrets.map.get(thisObject.p2pNetworkClientCodeName).privateKey)
|
||||
|
||||
let body = {
|
||||
messageId: SA.projects.foundations.utilities.miscellaneousFunctions.genereteUniqueId(),
|
||||
messageType: 'Request',
|
||||
signature: JSON.stringify(signature),
|
||||
payload: JSON.stringify(message)
|
||||
}
|
||||
|
||||
const data = JSON.stringify(body)
|
||||
const http = SA.nodeModules.http
|
||||
|
||||
const options = {
|
||||
hostname: thisObject.host,
|
||||
port: thisObject.port,
|
||||
path: '/New-Signal',
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': data.length
|
||||
}
|
||||
}
|
||||
|
||||
const req = http.request(options, res => {
|
||||
console.log(`statusCode: ${res.statusCode}`)
|
||||
|
||||
res.on('data', d => {
|
||||
process.stdout.write(d)
|
||||
})
|
||||
})
|
||||
|
||||
req.on('error', error => {
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
req.write(data)
|
||||
req.end()
|
||||
|
||||
return
|
||||
|
||||
/*
|
||||
const fetch = SA.nodeModules.nodeFetch
|
||||
const url = 'http://' + thisObject.host + ':' + thisObject.port + '/' + 'New-Signal'
|
||||
const options = {
|
||||
method: 'post',
|
||||
body: JSON.stringify(body),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
}
|
||||
const response = fetch(url)
|
||||
.then(returnData)
|
||||
.catch(onError)
|
||||
|
||||
function onError(errorMessage) {
|
||||
console.log('[ERROR] Error sending http request to P2P Network Node via httpInterdace: ' + errorMessage)
|
||||
}
|
||||
|
||||
async function returnData() {
|
||||
const data = await response.json();
|
||||
resolve(data)
|
||||
}
|
||||
*/
|
||||
/*
|
||||
} catch (err) {
|
||||
console.log('[ERROR] Http Network Client -> err.message = ' + err.message)
|
||||
reject(err.description)
|
||||
}
|
||||
|
||||
|
||||
} */
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ exports.newTradingSignalsModulesOutgoingTradingSignals = function (processIndex)
|
||||
function finalize() {
|
||||
}
|
||||
|
||||
function broadcastSignal(node) {
|
||||
async function broadcastSignal(node) {
|
||||
if (node === undefined) { return }
|
||||
if (node.outgoingSignals === undefined) { return }
|
||||
if (node.outgoingSignals.signalReferences === undefined) { return }
|
||||
@@ -30,7 +30,7 @@ exports.newTradingSignalsModulesOutgoingTradingSignals = function (processIndex)
|
||||
socialTradingBotNodeId: signalReference.referenceParent.id
|
||||
}
|
||||
|
||||
TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkStart.sendMessage(signalMessage)
|
||||
await TS.projects.foundations.globals.taskConstants.P2P_NETWORK.p2pNetworkStart.sendMessage(signalMessage)
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+58
-27868
File diff suppressed because it is too large.
Load diff
+23
-22
@@ -14,41 +14,23 @@
|
||||
"postsetup": "npm start",
|
||||
"dist": "electron-builder -c build/electron-builder.json",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"startNetwork" : "node network",
|
||||
"startNetwork": "node network",
|
||||
"startDesktop": "node desktop",
|
||||
"startDesktopReact": "node desktop-react"
|
||||
},
|
||||
"dependencies": {
|
||||
"@octokit/rest": "^18.12.0",
|
||||
"ccxt": "^1.61.93",
|
||||
"child_process": "^1.0.2",
|
||||
"electron-updater": "^4.6.1",
|
||||
"ethereumjs-common": "^1.5.2",
|
||||
"ethereumjs-tx": "^2.1.2",
|
||||
"ethers": "^5.5.1",
|
||||
"http": "0.0.1-security",
|
||||
"https": "^1.0.0",
|
||||
"ip": "^1.1.5",
|
||||
"lookpath": "^1.2.2",
|
||||
"node-fetch": "^2.6.6",
|
||||
"open": "^8.4.0",
|
||||
"path": "^0.12.7",
|
||||
"simple-git": "^2.47.0",
|
||||
"telegraf": "^4.4.2",
|
||||
"twitter": "^1.7.1",
|
||||
"util": "^0.12.4",
|
||||
"web3": "^1.6.1",
|
||||
"ws": "^8.2.3",
|
||||
"@babel/core": "7.12.3",
|
||||
"@emotion/react": "^11.6.0",
|
||||
"@emotion/styled": "^11.6.0",
|
||||
"@mui/icons-material": "^5.1.1",
|
||||
"@mui/material": "^5.1.1",
|
||||
"@octokit/rest": "^18.12.0",
|
||||
"@pmmmwh/react-refresh-webpack-plugin": "0.4.3",
|
||||
"@reduxjs/toolkit": "^1.6.2",
|
||||
"@svgr/webpack": "5.5.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.5.0",
|
||||
"@typescript-eslint/parser": "^4.5.0",
|
||||
"axios": "^0.24.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-jest": "^26.6.0",
|
||||
"babel-loader": "8.1.0",
|
||||
@@ -57,9 +39,12 @@
|
||||
"bfj": "^7.0.2",
|
||||
"camelcase": "^6.1.0",
|
||||
"case-sensitive-paths-webpack-plugin": "2.3.0",
|
||||
"ccxt": "^1.61.93",
|
||||
"child_process": "^1.0.2",
|
||||
"css-loader": "4.3.0",
|
||||
"dotenv": "8.2.0",
|
||||
"dotenv-expand": "5.1.0",
|
||||
"electron-updater": "^4.6.1",
|
||||
"eslint": "^7.11.0",
|
||||
"eslint-config-react-app": "^6.0.0",
|
||||
"eslint-plugin-flowtype": "^5.2.0",
|
||||
@@ -70,16 +55,26 @@
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"eslint-plugin-testing-library": "^3.9.2",
|
||||
"eslint-webpack-plugin": "^2.5.2",
|
||||
"ethereumjs-common": "^1.5.2",
|
||||
"ethereumjs-tx": "^2.1.2",
|
||||
"ethers": "^5.5.1",
|
||||
"file-loader": "6.1.1",
|
||||
"fs-extra": "^9.0.1",
|
||||
"html-webpack-plugin": "4.5.0",
|
||||
"http": "0.0.1-security",
|
||||
"https": "^1.0.0",
|
||||
"identity-obj-proxy": "3.0.0",
|
||||
"ip": "^1.1.5",
|
||||
"jest": "26.6.0",
|
||||
"jest-circus": "26.6.0",
|
||||
"jest-resolve": "26.6.0",
|
||||
"jest-watch-typeahead": "0.6.1",
|
||||
"lookpath": "^1.2.2",
|
||||
"mini-css-extract-plugin": "0.11.3",
|
||||
"node-fetch": "^2.6.6",
|
||||
"open": "^8.4.0",
|
||||
"optimize-css-assets-webpack-plugin": "5.0.4",
|
||||
"path": "^0.12.7",
|
||||
"pnp-webpack-plugin": "1.6.4",
|
||||
"postcss-flexbugs-fixes": "4.2.1",
|
||||
"postcss-loader": "3.0.0",
|
||||
@@ -99,15 +94,21 @@
|
||||
"resolve-url-loader": "^3.1.2",
|
||||
"sass-loader": "^10.0.5",
|
||||
"semver": "7.3.2",
|
||||
"simple-git": "^2.47.0",
|
||||
"style-loader": "1.3.0",
|
||||
"telegraf": "^4.4.2",
|
||||
"terser-webpack-plugin": "4.2.3",
|
||||
"ts-pnp": "1.2.0",
|
||||
"twitter": "^1.7.1",
|
||||
"url-loader": "4.1.1",
|
||||
"util": "^0.12.4",
|
||||
"web-vitals": "^1.1.2",
|
||||
"web3": "^1.6.1",
|
||||
"webpack": "4.44.2",
|
||||
"webpack-dev-server": "3.11.1",
|
||||
"webpack-manifest-plugin": "2.2.0",
|
||||
"workbox-webpack-plugin": "5.1.4"
|
||||
"workbox-webpack-plugin": "5.1.4",
|
||||
"ws": "^8.2.3"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@tensorflow/tfjs-node": "^2.8.6"
|
||||
|
||||
Reference in new issue
Block a user