From 572bdb68eef38a92b106daa59e3d0d82f8ac27bf Mon Sep 17 00:00:00 2001 From: ognjenkurtic Date: Sat, 20 Jan 2024 23:09:46 +0100 Subject: [PATCH] improve condition to check if the value or the default value of a circuit input is provided in the circuit input parser; Simplify calculateStringCharCodeSum call in case of string type --- .../circuitInputsParser/circuitInputParser.service.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/bri-3/src/bri/zeroKnowledgeProof/services/circuit/circuitInputsParser/circuitInputParser.service.ts b/examples/bri-3/src/bri/zeroKnowledgeProof/services/circuit/circuitInputsParser/circuitInputParser.service.ts index dd541ead0..05fe7be54 100644 --- a/examples/bri-3/src/bri/zeroKnowledgeProof/services/circuit/circuitInputsParser/circuitInputParser.service.ts +++ b/examples/bri-3/src/bri/zeroKnowledgeProof/services/circuit/circuitInputsParser/circuitInputParser.service.ts @@ -17,7 +17,7 @@ export class CircuitInputsParserService { mapping.payloadJsonPath, ); - if (!value && !mapping.defaultValue) { + if (value === undefined && mapping.defaultValue === undefined) { this.logger.logError( `Missing value and default value for mapping ${cim.mapping} while mapping circuit inputs for payload ${payload}`, ); @@ -26,9 +26,7 @@ export class CircuitInputsParserService { switch (mapping.dataType) { case 'string': - result[mapping.circuitInput] = value - ? this.calculateStringCharCodeSum(value) - : this.calculateStringCharCodeSum(mapping.defaultValue); + result[mapping.circuitInput] = this.calculateStringCharCodeSum(value || mapping.defaultValue); break; case 'integer':