From 65a24053aad5883b7fd54574de8b788ce49208e7 Mon Sep 17 00:00:00 2001 From: Rob Knight Date: Mon, 30 Sep 2024 17:32:13 -0700 Subject: [PATCH] Don't include is/NotMemberOf at all if not defined --- packages/podspec/src/gpc/proof_request.ts | 12 +++++------ .../ticket-spec/test/ticket-utils.spec.ts | 20 +++++++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/packages/podspec/src/gpc/proof_request.ts b/packages/podspec/src/gpc/proof_request.ts index 4dd6e1c..3334bcf 100644 --- a/packages/podspec/src/gpc/proof_request.ts +++ b/packages/podspec/src/gpc/proof_request.ts @@ -161,12 +161,12 @@ function makeProofRequest

( const entryConfig: GPCProofEntryConfig = { isRevealed, - isMemberOf: isMemberOf - ? `allowlist_${podName}_${entryName}` - : undefined, - isNotMemberOf: isNotMemberOf - ? `blocklist_${podName}_${entryName}` - : undefined, + ...(isMemberOf + ? { isMemberOf: `allowlist_${podName}_${entryName}` } + : {}), + ...(isNotMemberOf + ? { isNotMemberOf: `blocklist_${podName}_${entryName}` } + : {}), ...(inRange ? { inRange: entrySchema.inRange } : {}), ...(isOwnerID ? { isOwnerID: owner.protocol } : {}) }; diff --git a/packages/ticket-spec/test/ticket-utils.spec.ts b/packages/ticket-spec/test/ticket-utils.spec.ts index 919d179..648a4af 100644 --- a/packages/ticket-spec/test/ticket-utils.spec.ts +++ b/packages/ticket-spec/test/ticket-utils.spec.ts @@ -60,5 +60,25 @@ describe("ticket-utils", () => { externalNullifier: { type: "string", value: "1" }, watermark: { type: "string", value: "1" } }); + + const proofRequest = request.getProofRequest(); + expect(proofRequest.externalNullifier).toEqual({ + type: "string", + value: "1" + }); + expect(proofRequest.watermark).toEqual({ + type: "string", + value: "1" + }); + expect(Object.keys(proofRequest.membershipLists)).toHaveLength(0); + expect(proofRequest.proofConfig.pods.ticket).toBeDefined(); + // The owner entry is present because we specified an external nullifier + expect( + Object.keys(proofRequest.proofConfig.pods.ticket?.entries ?? {}) + ).toHaveLength(1); + expect(proofRequest.proofConfig.pods.ticket?.entries?.owner).toEqual({ + isOwnerID: "SemaphoreV4", + isRevealed: false + }); }); });