Skip to content

Commit

Permalink
chore: fixed the node inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
SwatiEY committed Aug 29, 2024
1 parent ad53bd5 commit 5f59d82
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ const internalCallVisitor = {
if(state.newStateArray[name][id].memberName)
state.newParameterList.splice(nodeIndex,1);
}
const params = state.newParameterList.map(node => node.name);
(state.paramNode && !(params.includes(state.paramNode.name))) ? state.newParameterList.push(state.paramNode) : state.newParameterList;
}
})
state.newReturnParameterList.forEach((node,nodeIndex) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ const internalCallVisitor = {
file.nodes.forEach(childNode => {
if(childNode.nodeType === 'FunctionDefinition') {
childNode.parameters.modifiedStateVariables = joinWithoutDupes(childNode.parameters.modifiedStateVariables, state.newParametersList);
const modifiedNodes = childNode.parameters.modifiedStateVariables.map(node => node.name);
if(state.decNode && !(modifiedNodes.includes(state.decNode.declarations[0].name)))
childNode.body.preStatements.splice(1, 0, state.decNode);
if(childNode.decrementedSecretStates)
childNode.decrementedSecretStates = [...new Set([...childNode.decrementedSecretStates, ...newdecrementedSecretStates])];
childNode.body.preStatements.forEach(node => {
Expand Down Expand Up @@ -527,7 +530,7 @@ FunctionCall: {
decNode.declarations[0].declarationType = 'state';
decNode.declarations[0].isAccessed = true;
decNode.declarations[0].interactsWithSecret = true;
callingfnDefPath.node._newASTPointer.body.preStatements.splice(1,0,decNode);
state.decNode = decNode;
const returnPara = functionReferncedNode.node.returnParameters.parameters[0].name;
newNode = buildNode('InternalFunctionCall', {
name: returnPara,
Expand Down
12 changes: 6 additions & 6 deletions src/transformers/visitors/toCircuitVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1588,12 +1588,12 @@ if(parent.nodeType === 'VariableDeclarationStatement') {
internalFunctionInteractsWithSecret: internalFunctionInteractsWithSecret, // return
});
if(parent._newASTPointer.declarations.length > 0){
const functionParams = callingfnDefPath.node._newASTPointer.parameters.parameters.map(param => param.name);
if(!functionParams.includes(returnPara)){
callingfnDefPath.node._newASTPointer.parameters.parameters.push(functionReferncedNode.node.returnParameters.parameters[0]._newASTPointer);
callingfnDefPath.node._newASTPointer.parameters.parameters[functionParams.length].declarationType = 'parameter';
callingfnDefPath.node._newASTPointer.parameters.parameters[functionParams.length].interactsWithSecret = true;
}}
// saving the return parameter to add in the circuits if it doesn't exist
state.paramNode = functionReferncedNode.node.returnParameters.parameters[0]._newASTPointer;
state.paramNode.declarationType = 'parameter';
state.paramNode.interactsWithSecret = true;

}
} else
{
newNode = buildNode('InternalFunctionCall', {
Expand Down

0 comments on commit 5f59d82

Please sign in to comment.