Keys integration cloud and browser
This commit is contained in:
1 parent
4cc17c19f8
commit
fd16e2700c
4 files changed
+21
-21
No files matched your search
+18
-18
@@ -1,4 +1,4 @@
|
||||
exports.newExchangeAPI = function newExchangeAPI(bot, logger) {
|
||||
exports.newExchangeAPI = function newExchangeAPI(logger, authToken) {
|
||||
|
||||
/*
|
||||
|
||||
@@ -35,7 +35,21 @@
|
||||
let exchange = botExchange.toLowerCase() + 'Client.js';
|
||||
let api = require('./wrappers/' + exchange);
|
||||
|
||||
let keyVaultAPI = createKeyVaultAPIClient()
|
||||
let accessToken
|
||||
let keyId
|
||||
let cloneId
|
||||
if (global.CURRENT_EXECUTION_AT === "Cloud") {
|
||||
keyId = process.env.KEY_ID
|
||||
cloneId = process.env.CLONE_ID
|
||||
|
||||
let auth = require('../utils/auth')
|
||||
let authTokenCloud = await auth.authenticate()
|
||||
accessToken = 'Bearer ' + authTokenCloud
|
||||
} else if (global.CURRENT_EXECUTION_AT === "Browser") {
|
||||
accessToken = 'Bearer ' + authToken
|
||||
}
|
||||
|
||||
let keyVaultAPI = createKeyVaultAPIClient(accessToken, keyId, cloneId)
|
||||
apiClient = api.newAPIClient(keyVaultAPI, logger);
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
@@ -46,23 +60,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
function createKeyVaultAPIClient() {
|
||||
function createKeyVaultAPIClient(accessToken, keyId, cloneId) {
|
||||
if (global.LOG_CONTROL[MODULE_NAME].logInfo === true) { logger.write(MODULE_NAME, "[INFO] createKeyVaultAPIClient -> Entering function."); }
|
||||
|
||||
let accessToken
|
||||
let keyId
|
||||
let cloneId
|
||||
if (global.CURRENT_EXECUTION_AT === "Cloud") {
|
||||
keyId = process.env.KEY_ID
|
||||
cloneId = process.env.CLONE_ID
|
||||
|
||||
let auth = require('../utils/auth')
|
||||
let authToken = await auth.authenticate()
|
||||
accessToken = 'Bearer ' + authToken
|
||||
} else if (global.CURRENT_EXECUTION_AT === "Browser") {
|
||||
accessToken = window.localStorage.getItem('access_token')
|
||||
}
|
||||
|
||||
|
||||
const keyVaultAPI = {}
|
||||
keyVaultAPI.signTransaction = function (transaction, next) {
|
||||
axios({
|
||||
|
||||
@@ -275,7 +275,7 @@
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeExchangeAPI -> Entering function."); }
|
||||
|
||||
exchangeAPI = EXCHANGE_API.newExchangeAPI(bot, logger);
|
||||
exchangeAPI = EXCHANGE_API.newExchangeAPI(logger);
|
||||
|
||||
exchangeAPI.initialize(onInizialized);
|
||||
|
||||
|
||||
@@ -350,7 +350,7 @@
|
||||
case "Browser": {
|
||||
let startMode = {
|
||||
live: { run: "false" },
|
||||
backtest: { run: "false" },
|
||||
backtest: { run: "false", waitTime: 5000 },
|
||||
competition: { run: "false" }
|
||||
}
|
||||
let browserStartMode = global.CURRENT_START_MODE.toLowerCase()
|
||||
|
||||
@@ -617,7 +617,7 @@
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] run -> loop -> initializeExchangeAPI -> Entering function."); }
|
||||
|
||||
exchangeAPI = EXCHANGE_API.newExchangeAPI(bot, logger);
|
||||
exchangeAPI = EXCHANGE_API.newExchangeAPI(logger);
|
||||
|
||||
exchangeAPI.initialize(onInizialized);
|
||||
|
||||
|
||||
Reference in new issue
Block a user