diff --git a/ExchangeAPI.js b/ExchangeAPI.js index fd4aefe4c..53250da1d 100644 --- a/ExchangeAPI.js +++ b/ExchangeAPI.js @@ -36,28 +36,10 @@ if (FULL_LOG === true) { logger.write("[INFO] initialize -> Entering function."); } - let apiKey = readApiKey(); - poloniexApiClient = new POLONIEX_CLIENT_MODULE(apiKey.Key, apiKey.Secret); + poloniexApiClient = new POLONIEX_CLIENT_MODULE(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret); callBackFunction(global.DEFAULT_OK_RESPONSE); - function readApiKey() { - - try { - let fs = require('fs'); - let filePath = '../' + 'API-Keys' + '/' + bot.codeName + '.' + global.EXCHANGE_NAME + '.json'; - return JSON.parse(fs.readFileSync(filePath, 'utf8')); - } - catch (err) { - logger.write("[ERROR] initialize -> readApiKey -> err = " + err.message); - logger.write("[HINT] You need to have a file at this path -> " + filePath); - logger.write("[HINT] The file must have the keys to access your poloniex account, in this format -> " + '{ "Key" : "4FB9TMEB-234VH2W1-BYJIXHGM-GL15DSA1", "Secret" : "1a24298skdjdf734uuyhbdagdasdtyut276587256hdsdas765asdasdasd76asdasda765asdasfas6asfda57657asd5a76sd5a7s65d7a6sd57as65d7as65d"}'); - logger.write("[HINT] You get this key logging in to your Poloniex web account, enabling API keys and getting a new one. "); - logger.write("[HINT] Be sure not to allow withdrawls with this Key. When asked at the exchange key page, say no. "); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); - } - } - } catch (err) { logger.write("[ERROR] initialize -> err = " + err.message); diff --git a/Run.js b/Run.js index 0a1bdcc04..6200aa8c0 100644 --- a/Run.js +++ b/Run.js @@ -1,8 +1,6 @@  - global.CURRENT_ENVIRONMENT = "Develop"; - process.on('uncaughtException', function (err) { console.log('[INFO] Run -> uncaughtException -> err.message = ' + err.message); return; @@ -30,9 +28,9 @@ process.on('exit', function (code) { global.STORAGE_PERMISSIONS = {}; -readConnectionStringConfigFile(); +readStoragePermissions(); -function readConnectionStringConfigFile(environment, devTeamDataOwner) { +function readStoragePermissions(environment, devTeamDataOwner) { let filePath; @@ -41,13 +39,36 @@ function readConnectionStringConfigFile(environment, devTeamDataOwner) { filePath = '../' + 'Connection-Strings' + '/' + 'Storage.Permissions.json'; global.STORAGE_PERMISSIONS = JSON.parse(fs.readFileSync(filePath, 'utf8')); + readApiKey(); + } + catch (err) { + console.log("[ERROR] readStoragePermissions -> err = " + err.message); + console.log("[HINT] readStoragePermissions -> You need to have a file at this path -> " + filePath); + callBackFunction(global.DEFAULT_FAIL_RESPONSE); + } +} + +function readApiKey() { + + try { + let fs = require('fs'); + let filePath = '../' + 'Exchange-Keys' + '/' + 'Secret.Keys' + '.json'; + + global.EXCHANGE_KEYS = JSON.parse(fs.readFileSync(filePath, 'utf8')); startRoot(); } catch (err) { - console.log("[ERROR] readConnectionStringConfigFile -> err = " + err.message); - console.log("[HINT] readConnectionStringConfigFile -> You need to have a file at this path -> " + filePath); - console.log("[HINT] readConnectionStringConfigFile -> The file must have the connection string to the Azure Storage Account. Request the file to an AA Team Member if you dont have it."); - callBackFunction(global.DEFAULT_FAIL_RESPONSE); + logger.write("[ERROR] readApiKey -> err = " + err.message); + logger.write("[HINT] You need to have a file at this path -> " + filePath); + + global.EXCHANGE_KEYS = { + Poloniex: { + Key: "", + Secret: "" + } + } + + startRoot(); } }