Skip to content

Commit

Permalink
chore: added a fix for a bug
Browse files Browse the repository at this point in the history
  • Loading branch information
SwatiEY committed Apr 4, 2024
1 parent c42542a commit fb60b1d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function buildPrivateStateNode(nodeType: string, fields: any = {}): any {
};
}
case 'WritePreimage': {
const { id, increment, burnedOnly, indicator = {} } = fields;
const { id, increment, burnedOnly, reinitialisedOnly, indicator = {} } = fields
return {
increment,
stateVarId: id,
Expand All @@ -64,6 +64,7 @@ export function buildPrivateStateNode(nodeType: string, fields: any = {}): any {
mappingName: indicator.isMapping ? indicator.node?.name : null,
nullifierRequired: indicator.isNullified,
burnedOnly,
reinitialisedOnly,
isOwned: indicator.isOwned,
mappingOwnershipType: indicator.mappingOwnershipType,
owner: indicator.isOwned
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Q: how are we merging mapping key and ownerPK in edge case?
// Q: should we reduce constraints a mapping's commitment's preimage by not having the extra inner hash? Not at the moment, because it adds complexity to transpilation.
import fs from 'fs';
import fs, { stat } from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

Expand Down Expand Up @@ -474,8 +474,9 @@ sendTransaction = {
mappingName,
mappingKey,
burnedOnly,
structProperties,
reinitialisedOnly,
structProperties,

}): string[] {
let value;
switch (stateType) {
Expand Down Expand Up @@ -521,7 +522,7 @@ sendTransaction = {
default:
value = structProperties ? `{ ${structProperties.map(p => `${p}: ${stateName}.${p}`)} }` : `${stateName}`;
return [`
\n${reinitialisedOnly? ' ': `if (${stateName}_commitmentExists) await markNullified(${stateName}_currentCommitment, secretKey.hex(32));`}
\n${reinitialisedOnly ? ' ': `if (${stateName}_commitmentExists) await markNullified(${stateName}_currentCommitment, secretKey.hex(32));`}
\nawait storeCommitment({
hash: ${stateName}_newCommitment,
name: '${mappingName}',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ export const generateProofBoilerplate = (node: any) => {

});
// then we build boilerplate code per state
console.log(stateNode);
switch (stateNode.isWhole) {
case true:
output.push(
Expand Down Expand Up @@ -596,7 +595,7 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => {
: ``,
burnedOnly: false,
structProperties: stateNode.structProperties,
reinitialisedOnly: stateNode.reinitialisedOnly,
reinitialisedOnly: false,
}));

break;
Expand Down Expand Up @@ -631,8 +630,9 @@ export const OrchestrationCodeBoilerPlate: any = (node: any) => {
? `${stateName}_stateVarId_key.integer`
: ``,
burnedOnly: stateNode.burnedOnly,
structProperties: stateNode.structProperties,
reinitialisedOnly: stateNode.reinitialisedOnly,
structProperties: stateNode.structProperties,

}));
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/transformers/visitors/toOrchestrationVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,9 +567,12 @@ const visitor = {
burnedOnly:
stateVarIndicator.isBurned &&
!stateVarIndicator.newCommitmentsRequired,
reinitialisedOnly: stateVarIndicator.reinitialisable &&
!stateVarIndicator.isNullified,
});
}
}


if (node.kind === 'constructor') {
newNodes.writePreimageNode.isConstructor = true;
Expand Down

0 comments on commit fb60b1d

Please sign in to comment.