Skip to content

Commit

Permalink
remove public parameters from custom inputs in orchestration (because…
Browse files Browse the repository at this point in the history
… they are already input anyway)
  • Loading branch information
lydiagarms committed Jul 11, 2024
1 parent cb83db9 commit c77a9e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
20 changes: 1 addition & 19 deletions src/boilerplate/orchestration/javascript/raw/toOrchestration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -894,28 +894,10 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => {
lines.push(`${input.name}.hex(20)`);
}
else {
lines.push(`${input.name}.integer`);
lines.push(`${input}.integer`);
}
});
}
if (node.publicInputs[0]) {
node.publicInputs.forEach((input: any) => {
if (input.inCircuit){
if (input.properties) {
returnInputs.push(`[${input.properties.map(p => p.type === 'bool' ? `(${input.name}${input.isConstantArray ? '.all' : ''}.${p.name}.integer === "1")` : `${input.name}${input.isConstantArray ? '.all' : ''}.${p.name}.integer`).join(',')}]`);
} else if (input.isConstantArray) {
returnInputs.push(`${input.name}.all.integer`);
} else if(input.isBool) {
returnInputs.push(`parseInt(${input.name}.integer, 10)`);
} else if(input.isAddress) {
returnInputs.push(`${input.name}.hex(20)`);
}
else {
returnInputs.push(`${input.name}.integer`);
}
}
});
}

if(node.returnInputs[0]) {
node.returnInputs.forEach((input: any) => {
Expand Down
5 changes: 2 additions & 3 deletions src/transformers/visitors/toOrchestrationVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -863,16 +863,15 @@ const visitor = {
// this adds other values we need in the tx
for (const param of node.parameters.parameters) {
if (!param.isSecret) {
//if (path.isStructDeclaration(param) || path.isConstantArray(param) ||( param.typeName && param.typeName.name === 'bool') || ( param.typeName && param.typeName.name === 'address')) {
if (path.isStructDeclaration(param) || path.isConstantArray(param) ||( param.typeName && param.typeName.name === 'bool') || ( param.typeName && param.typeName.name === 'address')) {
let newParam: any = {};
newParam.name = param.name;
if (param._newASTPointer.interactsWithSecret) newParam.inCircuit = true;
if (path.isStructDeclaration(param)) newParam.properties = param._newASTPointer.typeName.properties.map(p => ({"name" : p.name, "type" : p.type }));
if (path.isConstantArray(param)) newParam.isConstantArray = true;
if (param.typeName?.name === 'bool') newParam.isBool = true;
if (param.typeName?.name === 'address') newParam.isAddress = true;
newNodes.sendTransactionNode.publicInputs.push(newParam);
//} else newNodes.sendTransactionNode.publicInputs.push(param.name);
} else newNodes.sendTransactionNode.publicInputs.push(param.name);
}
}
// this adds the return parameters which are marked as secret in the tx
Expand Down

0 comments on commit c77a9e0

Please sign in to comment.