Skip to content

Commit

Permalink
fix: _ instead of . in circuit causing compilation error for SimpleSt…
Browse files Browse the repository at this point in the history
…ruct2 and for incremented non-structs alllow for multiple incrementations
  • Loading branch information
lydiagarms committed Jul 8, 2024
1 parent 68fe11c commit 1f65c4c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ class BoilerplateGenerator {

}
else {
lines.push(`${typeName} ${x}_newCommitment_value = ${typeName} { ${structProperties.map(p => ` ${p}: ${isWhole ? `${y}.${p}` : `${y}_${p}`}`)} }\n`);
lines.push(`${typeName} ${x}_newCommitment_value = ${typeName} { ${structProperties.map(p => ` ${p}: ${y}.${p}`)} }\n`);
if (structPropertiesTypes) {
structPropertiesTypes.forEach(property => {
if (property.typeName === 'bool'){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ class BoilerplateGenerator {
\n\n// read preimage for incremented state
${stateName}_newOwnerPublicKey = ${newOwnerStatment}
${stateVarIds.join('\n')}
\n`];
\n
let ${stateName}_newCommitmentValue = generalise(0);
`];
case 'decrement':
if (structProperties)
return [`
Expand Down
5 changes: 3 additions & 2 deletions src/codeGenerators/orchestration/nodejs/toOrchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,14 @@ export default function codeGenerator(node: any, options: any = {}): any {

if (node.incrementsSecretState && (node.interactsWithSecret || node.expression?.internalFunctionInteractsWithSecret)){
let privateStateName = node.privateStateName.replace(/\./g, '_');
let increments = codeGenerator(node.expression.rightHandSide);
if (typeof node.increments === 'object' && node.increments !== null) {
if (node.expression.leftHandSide.nodeType === 'MemberAccess'){
let propName = node.expression.leftHandSide.memberName;
return `\nconst ${privateStateName}_newCommitmentValue = generalise(${node.increments[propName]});\n`;
return `\n${privateStateName}_newCommitmentValue = generalise(${node.increments[propName]});\n`;
}
};
return `\nconst ${privateStateName}_newCommitmentValue = generalise(${node.increments});\n`;
return `\n${privateStateName}_newCommitmentValue = generalise(parseInt(${privateStateName}_newCommitmentValue.integer, 10) + ${increments});\n`;
}

if (!node.interactsWithSecret)
Expand Down

0 comments on commit 1f65c4c

Please sign in to comment.