Skip to content

Commit f7e9c40

Browse files
transphormNesopie
authored andcommitted
fix: OFAC trees not found (#1060)
* fix: relax OFAC tree response validation * test: cover OFAC tree edge cases * fix stateless * revert and fix types * fix tests
1 parent 74605c0 commit f7e9c40

File tree

6 files changed

+537
-9
lines changed

6 files changed

+537
-9
lines changed

app/src/utils/proving/provingMachine.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818
} from '@selfxyz/common/utils';
1919
import { getPublicKey, verifyAttestation } from '@selfxyz/common/utils/attest';
2020
import {
21+
generateTEEInputsDiscloseStateless,
2122
generateTEEInputsDSC,
2223
generateTEEInputsRegister,
2324
} from '@selfxyz/common/utils/circuits/registerInputs';
@@ -38,7 +39,6 @@ import {
3839
} from '@selfxyz/common/utils/proving';
3940
import {
4041
clearPassportData,
41-
generateTEEInputsDisclose,
4242
hasAnyValidRegisteredDocument,
4343
loadSelectedDocument,
4444
markCurrentDocumentAsRegistered,
@@ -459,7 +459,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
459459
selfClient.emit(SdkEvents.PROVING_REGISTER_ERROR_OR_FAILURE, {
460460
hasValidDocument: hasValid,
461461
});
462-
} catch (error) {
462+
} catch {
463463
selfClient.emit(SdkEvents.PROVING_REGISTER_ERROR_OR_FAILURE, {
464464
hasValidDocument: false,
465465
});
@@ -1015,7 +1015,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
10151015
}
10161016
},
10171017

1018-
_closeConnections: (selfClient: SelfClient) => {
1018+
_closeConnections: (_selfClient: SelfClient) => {
10191019
const { wsConnection: ws, wsHandlers } = get();
10201020
if (ws && wsHandlers) {
10211021
try {
@@ -1088,10 +1088,27 @@ export const useProvingStore = create<ProvingState>((set, get) => {
10881088
break;
10891089
case 'disclose':
10901090
({ inputs, circuitName, endpointType, endpoint } =
1091-
generateTEEInputsDisclose(
1091+
generateTEEInputsDiscloseStateless(
10921092
secret as string,
10931093
passportData,
10941094
selfApp as SelfApp,
1095+
(doc: DocumentCategory, tree) => {
1096+
const docStore =
1097+
doc === 'passport'
1098+
? protocolStore.passport
1099+
: protocolStore.id_card;
1100+
switch (tree) {
1101+
case 'ofac':
1102+
return docStore.ofac_trees;
1103+
case 'commitment':
1104+
if (!docStore.commitment_tree) {
1105+
throw new Error('Commitment tree not loaded');
1106+
}
1107+
return docStore.commitment_tree;
1108+
default:
1109+
throw new Error('Unknown tree type');
1110+
}
1111+
},
10951112
));
10961113
circuitTypeWithDocumentExtension = `disclose`;
10971114
break;

0 commit comments

Comments
 (0)