Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions app/src/utils/proving/provingMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from '@selfxyz/common/utils';
import { getPublicKey, verifyAttestation } from '@selfxyz/common/utils/attest';
import {
generateTEEInputsDiscloseStateless,
generateTEEInputsDSC,
generateTEEInputsRegister,
} from '@selfxyz/common/utils/circuits/registerInputs';
Comment on lines +21 to 24
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Switch to stateless disclose generator looks correct.

Import replacement aligns with resolver-based tree access. Verify no remaining imports/usages of the legacy generateTEEInputsDisclose across the repo.


🏁 Script executed:

#!/bin/bash
# Find lingering imports/usages of the legacy generator.
rg -nP "(generateTEEInputsDisclose[^S]|from ['\"][^\"']*generate-disclosure-inputs[^\"']*['\"])|generateTEEInputsDisclose\(" -C2

Length of output: 6325


Action: Remove remaining stateful generateTEEInputsDisclose usages — migrate callers/exports/tests to the stateless API

The stateless switch is correct, but the legacy stateful wrapper/export and tests still exist and must be removed/refactored.

  • packages/mobile-sdk-alpha/src/processing/generate-disclosure-inputs.ts — defines/exported generateTEEInputsDisclose and calls useProtocolStore.getState(); refactor to accept a getTree callback or export the stateless generator directly.
  • packages/mobile-sdk-alpha/src/index.ts and packages/mobile-sdk-alpha/src/browser.ts — currently re-export generateTEEInputsDisclose; update exports to the stateless variant or remove this export.
  • packages/mobile-sdk-alpha/tests/processing/generate-disclosure-inputs.test.ts — tests import the legacy function; update to exercise the stateless API (mock getTree) or adjust expectations.
  • app/tests/utils/proving/provingMachine.generatePayload.test.ts — mocks generateTEEInputsDisclose; update mocks to the stateless function.
  • packages/mobile-sdk-alpha/docs/MIGRATION_PROMPTS.md — migration notes still reference moving generateTEEInputsDisclose; update documentation to reflect the new stateless API.

Blocking: do not merge until the above references are removed or migrated to the stateless generator.

🤖 Prompt for AI Agents
In app/src/utils/proving/provingMachine.ts around lines 21 to 24, the code still
imports the legacy stateful generateTEEInputsDisclose; remove all remaining
stateful usages and migrate callers/exports/tests to the stateless API by:
replace imports/exports of generateTEEInputsDisclose with the new stateless
generateTEEInputsDiscloseStateless (or export the stateless generator directly),
refactor packages/mobile-sdk-alpha/src/processing/generate-disclosure-inputs.ts
to stop calling useProtocolStore.getState() and instead accept a getTree
callback or call the stateless generator directly, update
packages/mobile-sdk-alpha/src/index.ts and browser.ts to re-export the stateless
function (or drop the export), change
packages/mobile-sdk-alpha/tests/processing/generate-disclosure-inputs.test.ts
and app/tests/utils/proving/provingMachine.generatePayload.test.ts to
mock/invoke the stateless API (provide a getTree mock), and update
packages/mobile-sdk-alpha/docs/MIGRATION_PROMPTS.md to reflect the stateless
API; ensure all references to the legacy wrapper are removed before merging.

Expand All @@ -38,7 +39,6 @@ import {
} from '@selfxyz/common/utils/proving';
import {
clearPassportData,
generateTEEInputsDisclose,
hasAnyValidRegisteredDocument,
loadSelectedDocument,
markCurrentDocumentAsRegistered,
Expand Down Expand Up @@ -459,7 +459,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
selfClient.emit(SdkEvents.PROVING_REGISTER_ERROR_OR_FAILURE, {
hasValidDocument: hasValid,
});
} catch (error) {
} catch {
selfClient.emit(SdkEvents.PROVING_REGISTER_ERROR_OR_FAILURE, {
hasValidDocument: false,
});
Expand Down Expand Up @@ -1015,7 +1015,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
}
},

_closeConnections: (selfClient: SelfClient) => {
_closeConnections: (_selfClient: SelfClient) => {
const { wsConnection: ws, wsHandlers } = get();
if (ws && wsHandlers) {
try {
Expand Down Expand Up @@ -1088,10 +1088,27 @@ export const useProvingStore = create<ProvingState>((set, get) => {
break;
case 'disclose':
({ inputs, circuitName, endpointType, endpoint } =
generateTEEInputsDisclose(
generateTEEInputsDiscloseStateless(
secret as string,
passportData,
selfApp as SelfApp,
(doc: DocumentCategory, tree) => {
const docStore =
doc === 'passport'
? protocolStore.passport
: protocolStore.id_card;
switch (tree) {
case 'ofac':
return docStore.ofac_trees;
case 'commitment':
if (!docStore.commitment_tree) {
throw new Error('Commitment tree not loaded');
}
return docStore.commitment_tree;
default:
throw new Error('Unknown tree type');
}
},
));
circuitTypeWithDocumentExtension = `disclose`;
break;
Expand Down
Loading
Loading