From aedc957f204440a29da928f3997c9d1c6c1a985c Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 10 Aug 2019 18:24:48 +0200 Subject: [PATCH] Reading the exact fields from the designer --- Run.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Run.js b/Run.js index 979d075be..aec97a177 100644 --- a/Run.js +++ b/Run.js @@ -68,11 +68,30 @@ function sequenceExecution(currentStep, notFirstSequence) { execution.exchangeName ? global.EXCHANGE_NAME = execution.exchangeName : undefined; - if (definition.personalData) { - process.env.KEY = definition.personalData.exchangeAccounts[0].keys[0].code; - process.env.SECRET = definition.personalData.exchangeAccounts[0].keys[1].code; + if (definition) + { + if (definition.personalData) { + if (definition.personalData.exchangeAccounts) { + if (definition.personalData.exchangeAccounts.length > 0) { + let exchangeAccount = definition.personalData.exchangeAccounts[0] + if (exchangeAccount.keys) { + if (exchangeAccount.keys.length > 0) { + let key = exchangeAccount.keys[0] + try { + let data = JSON.parse(key.code) + process.env.KEY = data.label + process.env.SECRET = data.secret + } catch (err) { + // No need to do anything if data is wrong for now. + } + } + } + } + } + } } + let stepKey = execution.devTeam + '.' + execution.bot + '.' + execution.process; if (processedSteps.has(stepKey)) { processedSteps.set(stepKey, processedSteps.get(stepKey) + 1);