mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
move clearPassportData, markCurrentDocumentAsRegistered, reStorePassportDataWithRightCSCA to SDK (#1041)
This commit is contained in:
committed by
GitHub
parent
4db3734b75
commit
f416211037
@@ -37,8 +37,11 @@ import {
|
||||
getWSDbRelayerUrl,
|
||||
} from '@selfxyz/common/utils/proving';
|
||||
import {
|
||||
clearPassportData,
|
||||
hasAnyValidRegisteredDocument,
|
||||
loadSelectedDocument,
|
||||
markCurrentDocumentAsRegistered,
|
||||
reStorePassportDataWithRightCSCA,
|
||||
SdkEvents,
|
||||
SelfClient,
|
||||
} from '@selfxyz/mobile-sdk-alpha';
|
||||
@@ -48,12 +51,6 @@ import {
|
||||
} from '@selfxyz/mobile-sdk-alpha/constants/analytics';
|
||||
import { useProtocolStore } from '@selfxyz/mobile-sdk-alpha/stores';
|
||||
|
||||
// will need to be passed in from selfClient
|
||||
import {
|
||||
clearPassportData,
|
||||
markCurrentDocumentAsRegistered,
|
||||
reStorePassportDataWithRightCSCA,
|
||||
} from '@/providers/passportDataProvider';
|
||||
import { useSelfAppStore } from '@/stores/selfAppStore';
|
||||
import analytics from '@/utils/analytics';
|
||||
import { generateTEEInputsDisclose } from '@/utils/proving/provingInputs';
|
||||
@@ -261,7 +258,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
if (get().circuitType === 'register') {
|
||||
(async () => {
|
||||
try {
|
||||
await markCurrentDocumentAsRegistered();
|
||||
await markCurrentDocumentAsRegistered(selfClient);
|
||||
} catch (error) {
|
||||
//This will be checked and updated when the app launches the next time
|
||||
console.error('Error marking document as registered:', error);
|
||||
@@ -695,7 +692,7 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
}
|
||||
},
|
||||
|
||||
validatingDocument: async (_selfClient: SelfClient) => {
|
||||
validatingDocument: async (selfClient: SelfClient) => {
|
||||
_checkActorInitialized(actor);
|
||||
// TODO: for the disclosure, we could check that the selfApp is a valid one.
|
||||
trackEvent(ProofEvents.VALIDATION_STARTED);
|
||||
@@ -718,7 +715,9 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
status: isSupported.status,
|
||||
details: isSupported.details,
|
||||
});
|
||||
await clearPassportData();
|
||||
|
||||
await clearPassportData(selfClient);
|
||||
|
||||
actor!.send({ type: 'PASSPORT_NOT_SUPPORTED' });
|
||||
return;
|
||||
}
|
||||
@@ -755,12 +754,16 @@ export const useProvingStore = create<ProvingState>((set, get) => {
|
||||
},
|
||||
);
|
||||
if (isRegistered) {
|
||||
reStorePassportDataWithRightCSCA(passportData, csca as string);
|
||||
await reStorePassportDataWithRightCSCA(
|
||||
selfClient,
|
||||
passportData,
|
||||
csca as string,
|
||||
);
|
||||
|
||||
// Mark document as registered since its already onChain
|
||||
(async () => {
|
||||
try {
|
||||
await markCurrentDocumentAsRegistered();
|
||||
await markCurrentDocumentAsRegistered(selfClient);
|
||||
} catch (error) {
|
||||
//it will be checked and marked as registered during next app launch
|
||||
console.error('Error marking document as registered:', error);
|
||||
|
||||
Reference in New Issue
Block a user