From eb6e07a7d267254e82b7140ea3f81d6ac4478c49 Mon Sep 17 00:00:00 2001 From: MirandaWood Date: Mon, 23 Jan 2023 16:46:30 +0000 Subject: [PATCH] fix: remove reliance on config + api path fix --- .../orchestration/javascript/raw/boilerplate-generator.ts | 2 +- src/transformers/visitors/checks/accessedVisitor.ts | 2 +- src/transformers/visitors/checks/incrementedVisitor.ts | 2 +- src/traverse/Binding.ts | 2 +- src/utils/logger.ts | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts b/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts index 2fd5a5773..75b86f2d1 100644 --- a/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts +++ b/src/boilerplate/orchestration/javascript/raw/boilerplate-generator.ts @@ -721,7 +721,7 @@ zappFilesBoilerplate = () => { generic: true, }, { - readPath: 'src/boilerplate/common/api.mjs', + readPath: pathPrefix + '/api.mjs', writePath: './orchestration/api.mjs', generic: true, }, diff --git a/src/transformers/visitors/checks/accessedVisitor.ts b/src/transformers/visitors/checks/accessedVisitor.ts index 26e37d42c..0ea17cda1 100644 --- a/src/transformers/visitors/checks/accessedVisitor.ts +++ b/src/transformers/visitors/checks/accessedVisitor.ts @@ -142,7 +142,7 @@ export default { // end of error checking // ------ logger.debug(`Found an accessed secret state ${node.name}`); - if (config.get('log_level') === 'debug') backtrace.getSourceCode(node.src); + if (logger.level === 'debug') backtrace.getSourceCode(node.src); scope.getReferencedBinding(node)?.updateAccessed(path); const indicator = scope.getReferencedIndicator(node); if (indicator instanceof StateVariableIndicator) indicator.updateAccessed(path); diff --git a/src/transformers/visitors/checks/incrementedVisitor.ts b/src/transformers/visitors/checks/incrementedVisitor.ts index c7d31e1da..0e14a9b9f 100644 --- a/src/transformers/visitors/checks/incrementedVisitor.ts +++ b/src/transformers/visitors/checks/incrementedVisitor.ts @@ -175,7 +175,7 @@ export default { expressionNode.isDecremented = isDecremented; // print if in debug mode - if (config.get('log_level') === 'debug') backtrace.getSourceCode(node.src); + if (logger.level === 'debug') backtrace.getSourceCode(node.src); logger.debug(`statement is incremented? ${isIncremented}`); if (isIncremented && !isDecremented) { const incs = []; diff --git a/src/traverse/Binding.ts b/src/traverse/Binding.ts index a2413fc01..c89a7078e 100644 --- a/src/traverse/Binding.ts +++ b/src/traverse/Binding.ts @@ -630,7 +630,7 @@ export class VariableBinding extends Binding { logger.debug( `Found a statement which burns the secret state and allows it to be reinitialised. If this line isn't meant to do that, check why you are setting the address to 0.`, ); - if (config.get('log_level') === 'debug') backtrace.getSourceCode(node.src); + if (logger.level === 'debug') backtrace.getSourceCode(node.src); this.isBurned = true; // TODO more useful indicators here } diff --git a/src/utils/logger.ts b/src/utils/logger.ts index 156c00102..49324467b 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -17,7 +17,7 @@ function formatWithInspect(val: any) { } export default createLogger({ - level: config.get('log_level') || 'info', // can be also edited using CLI option --log-level + level: config.has('log_level') ? config.get('log_level') : 'info', // can be also edited using CLI option --log-level format: winston.format.combine( format.errors({ stack: true }), format.colorize(),