Skip to content

Conversation

@shazarre
Copy link
Collaborator

@shazarre shazarre commented Oct 1, 2025

Based on @aaronmgdr work in #1154 this PR introduces first high level hook (usePrepareDocumentProof) for interacting with SDK as a PoC in ConfirmBelongingSreen.


Note

Introduces usePrepareDocumentProof in the SDK and refactors ConfirmBelongingScreen to rely on it for proof readiness and confirmation, updating exports accordingly.

  • SDK:
    • New Hook: Adds usePrepareDocumentProof in packages/mobile-sdk-alpha/src/context.tsx to initialize proving (based on loadSelectedDocument) and expose isReadyToProve and setUserConfirmed.
    • Exports: Re-exports usePrepareDocumentProof from packages/mobile-sdk-alpha/src/browser.ts and packages/mobile-sdk-alpha/src/index.ts.
  • App:
    • Refactor: Updates app/src/screens/prove/ConfirmBelongingScreen.tsx to use usePrepareDocumentProof instead of manual proving store/init logic; simplifies effect and readiness handling.

Written by Cursor Bugbot for commit feb40c4. This will update automatically on new commits. Configure here.

Summary by CodeRabbit

  • New Features

    • Added a public hook in the mobile SDK to prepare document proofs, exposing readiness state and user confirmation control.
    • SDK exports updated to include the new hook across package entry points.
  • Refactor

    • Confirm Belonging screen now uses the new proof-preparation flow for readiness and user confirmation, removing prior document-loading initialization.
    • Preserves confirmation, notification permission, token storage, navigation, and error reporting while simplifying lifecycle and coupling.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 1, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Replaces direct ProvingStore usage in ConfirmBelongingScreen with a new SDK hook usePrepareDocumentProof; the hook loads the selected document, initializes proving mode, exposes isReadyToProve and setUserConfirmed, and is exported from the SDK; component initialization side-effects and store init calls are removed.

Changes

Cohort / File(s) Summary
App screen refactor
app/src/screens/prove/ConfirmBelongingScreen.tsx
Replaces useProvingStore usage with usePrepareDocumentProof from SDK; removes prior document-loading/init side-effect; uses isReadyToProve to gate UI flow and calls setUserConfirmed on confirmation; retains notification permission, FCM token storage, error logging, analytics, and navigation logic.
SDK: new hook & init flow
packages/mobile-sdk-alpha/src/context.tsx
Adds usePrepareDocumentProof hook that reads proving refs/state, calls loadSelectedDocument(selfClient) on mount, computes isReadyToProve, and initializes proving mode (register for Aadhaar else dsc) with error fallback. Exposes isReadyToProve and setUserConfirmed.
SDK: public API exports
packages/mobile-sdk-alpha/src/index.ts, packages/mobile-sdk-alpha/src/browser.ts
Adds usePrepareDocumentProof to exports alongside SelfClientContext, SelfClientProvider, and useSelfClient, expanding the SDK public surface.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Screen as ConfirmBelongingScreen
  participant Hook as usePrepareDocumentProof (SDK)
  participant Client as SelfClient
  participant Util as loadSelectedDocument
  participant Nav as Navigation

  rect rgb(240,248,255)
    note right of Screen: Component mounts
    Screen->>Hook: call usePrepareDocumentProof()
    Hook->>Client: read proving refs/state
    Hook->>Util: loadSelectedDocument(Client)
    alt load succeeds
      Util-->>Hook: selectedDocument
      Hook->>Hook: init proving (register if Aadhaar else dsc)
    else load fails
      Util-->>Hook: error
      Hook->>Hook: init proving (fallback dsc)
    end
    Hook-->>Screen: { isReadyToProve, setUserConfirmed }
  end

  rect rgb(245,255,240)
    note right of User: User taps OK
    User->>Screen: OK
    Screen->>Screen: request notification perms & store FCM token
    Screen->>Hook: setUserConfirmed()
    Screen->>Nav: navigate to loading
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

codex

Suggested reviewers

  • aaronmgdr
  • transphorm

Poem

A hook awakes where stores once lay,
Documents fetched to light the way.
Ready flag set, the user agrees,
Tokens kept safe, the flow proceeds.
Exports cheer — small, tidy spree ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title “introduce usePrepareDocumentProof in mobile SDK” clearly and concisely describes the primary change of adding the new hook to the SDK and reflects its integration focus; it avoids unnecessary detail and aligns with the main changeset without introducing unrelated information.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch shazarre/poc_high_level_hook

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3910abc and feb40c4.

📒 Files selected for processing (1)
  • packages/mobile-sdk-alpha/src/browser.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
packages/mobile-sdk-alpha/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/mobile-sdk-alpha/AGENTS.md)

packages/mobile-sdk-alpha/**/*.{ts,tsx}: Use strict TypeScript type checking across the codebase
Follow ESLint TypeScript-specific rules
Avoid introducing circular dependencies

Files:

  • packages/mobile-sdk-alpha/src/browser.ts
**/*.{js,ts,tsx,jsx,sol,nr}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{js,ts,tsx,jsx,sol,nr}: NEVER log sensitive data including PII (names, DOB, passport numbers, addresses), credentials, tokens, API keys, private keys, or session identifiers.
ALWAYS redact/mask sensitive fields in logs using consistent patterns (e.g., ***-***-1234 for passport numbers, J*** D*** for names).

Files:

  • packages/mobile-sdk-alpha/src/browser.ts
packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}: Review alpha mobile SDK code for:

  • API consistency with core SDK
  • Platform-neutral abstractions
  • Performance considerations
  • Clear experimental notes or TODOs

Files:

  • packages/mobile-sdk-alpha/src/browser.ts
🧠 Learnings (2)
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/src/index.ts : Re-export new SDK modules via packages/mobile-sdk-alpha/src/index.ts

Applied to files:

  • packages/mobile-sdk-alpha/src/browser.ts
📚 Learning: 2025-08-29T15:31:15.924Z
Learnt from: CR
PR: selfxyz/self#0
File: packages/mobile-sdk-alpha/AGENTS.md:0-0
Timestamp: 2025-08-29T15:31:15.924Z
Learning: Applies to packages/mobile-sdk-alpha/{**/*.test.{ts,tsx},**/__tests__/**/*.{ts,tsx}} : Use actual imports from selfxyz/mobile-sdk-alpha in tests

Applied to files:

  • packages/mobile-sdk-alpha/src/browser.ts
⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-deps
  • GitHub Check: e2e-ios
  • GitHub Check: analyze-ios
  • GitHub Check: analyze-android

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@shazarre shazarre marked this pull request as ready for review October 1, 2025 11:04
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1856c9b and db9a9b6.

📒 Files selected for processing (3)
  • app/src/screens/prove/ConfirmBelongingScreen.tsx (2 hunks)
  • packages/mobile-sdk-alpha/src/context.tsx (2 hunks)
  • packages/mobile-sdk-alpha/src/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
packages/mobile-sdk-alpha/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/mobile-sdk-alpha/AGENTS.md)

packages/mobile-sdk-alpha/**/*.{ts,tsx}: Use strict TypeScript type checking across the codebase
Follow ESLint TypeScript-specific rules
Avoid introducing circular dependencies

Files:

  • packages/mobile-sdk-alpha/src/context.tsx
  • packages/mobile-sdk-alpha/src/index.ts
**/*.{js,ts,tsx,jsx,sol,nr}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{js,ts,tsx,jsx,sol,nr}: NEVER log sensitive data including PII (names, DOB, passport numbers, addresses), credentials, tokens, API keys, private keys, or session identifiers.
ALWAYS redact/mask sensitive fields in logs using consistent patterns (e.g., ***-***-1234 for passport numbers, J*** D*** for names).

Files:

  • packages/mobile-sdk-alpha/src/context.tsx
  • packages/mobile-sdk-alpha/src/index.ts
  • app/src/screens/prove/ConfirmBelongingScreen.tsx
packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}: Review alpha mobile SDK code for:

  • API consistency with core SDK
  • Platform-neutral abstractions
  • Performance considerations
  • Clear experimental notes or TODOs

Files:

  • packages/mobile-sdk-alpha/src/context.tsx
  • packages/mobile-sdk-alpha/src/index.ts
packages/mobile-sdk-alpha/src/index.ts

📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)

Re-export new SDK modules via packages/mobile-sdk-alpha/src/index.ts

Files:

  • packages/mobile-sdk-alpha/src/index.ts
app/**/*.{ts,tsx}

📄 CodeRabbit inference engine (app/AGENTS.md)

Type checking must pass before PRs (yarn types)

Files:

  • app/src/screens/prove/ConfirmBelongingScreen.tsx
app/src/**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:

  • Component architecture and reusability
  • State management patterns
  • Performance optimizations
  • TypeScript type safety
  • React hooks usage and dependencies
  • Navigation patterns

Files:

  • app/src/screens/prove/ConfirmBelongingScreen.tsx
🧠 Learnings (2)
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
PR: selfxyz/self#936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: SelfClientProvider is wrapped in app/App.tsx, providing context for useSelfClient() hook usage throughout the React Native app navigation stacks.

Applied to files:

  • packages/mobile-sdk-alpha/src/context.tsx
📚 Learning: 2025-08-24T18:54:04.809Z
Learnt from: CR
PR: selfxyz/self#0
File: .cursor/rules/mobile-sdk-migration.mdc:0-0
Timestamp: 2025-08-24T18:54:04.809Z
Learning: Applies to packages/mobile-sdk-alpha/src/index.ts : Re-export new SDK modules via packages/mobile-sdk-alpha/src/index.ts

Applied to files:

  • packages/mobile-sdk-alpha/src/index.ts
🧬 Code graph analysis (2)
packages/mobile-sdk-alpha/src/context.tsx (2)
packages/mobile-sdk-alpha/src/index.ts (3)
  • usePrepareDocumentProof (75-75)
  • useSelfClient (74-74)
  • loadSelectedDocument (85-85)
packages/mobile-sdk-alpha/src/proving/provingMachine.ts (1)
  • useProvingStore (367-1417)
app/src/screens/prove/ConfirmBelongingScreen.tsx (2)
packages/mobile-sdk-alpha/src/context.tsx (1)
  • usePrepareDocumentProof (71-98)
packages/mobile-sdk-alpha/src/index.ts (1)
  • usePrepareDocumentProof (75-75)
🪛 GitHub Actions: Mobile SDK CI
packages/mobile-sdk-alpha/src/context.tsx

[error] 5-5: simple-import-sort/imports: Run autofix to sort these imports.

packages/mobile-sdk-alpha/src/index.ts

[warning] 1-1: Code style issues found in src/index.ts. Run Prettier with --write to fix.

🪛 GitHub Actions: Web CI
app/src/screens/prove/ConfirmBelongingScreen.tsx

[error] 11-11: Build failed: usePrepareDocumentProof is not exported by '@selfxyz/mobile-sdk-alpha' (imported in ConfirmBelongingScreen.tsx). Ensure the function is exported by the package version in use or adjust the import.

🪛 GitHub Actions: Workspace CI
packages/mobile-sdk-alpha/src/context.tsx

[error] 5-5: simple-import-sort/imports: Run autofix to sort these imports!

🪛 GitHub Check: lint
packages/mobile-sdk-alpha/src/context.tsx

[failure] 5-5:
Run autofix to sort these imports!


[failure] 71-71:
Expected usePrepareDocumentProof before useSelfClient

packages/mobile-sdk-alpha/src/index.ts

[warning] 71-71:
Replace ⏎··SelfClientContext,⏎··SelfClientProvider,⏎··useSelfClient,⏎··usePrepareDocumentProof⏎ with ·SelfClientContext,·SelfClientProvider,·useSelfClient,·usePrepareDocumentProof·


[failure] 71-71:
Expected usePrepareDocumentProof before useSelfClient

🪛 GitHub Check: workspace-lint
packages/mobile-sdk-alpha/src/context.tsx

[failure] 5-5:
Run autofix to sort these imports!


[failure] 71-71:
Expected usePrepareDocumentProof before useSelfClient

packages/mobile-sdk-alpha/src/index.ts

[warning] 71-71:
Replace ⏎··SelfClientContext,⏎··SelfClientProvider,⏎··useSelfClient,⏎··usePrepareDocumentProof⏎ with ·SelfClientContext,·SelfClientProvider,·useSelfClient,·usePrepareDocumentProof·


[failure] 71-71:
Expected usePrepareDocumentProof before useSelfClient

app/src/screens/prove/ConfirmBelongingScreen.tsx

[warning] 11-11:
Replace ·usePrepareDocumentProof,·useSelfClient· with ⏎··usePrepareDocumentProof,⏎··useSelfClient,⏎

⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-deps
  • GitHub Check: e2e-ios
  • GitHub Check: android-build-test
  • GitHub Check: analyze-android
  • GitHub Check: analyze-ios

Comment on lines +84 to +91
init(selfClient, 'register');
} else {
init(selfClient, 'dsc');
}
} catch (error) {
console.error('Error loading selected document:', error);
init(selfClient, 'dsc');
}
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 1, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Await init call
Line 84 and Line 86 invoke init without awaiting. Because init returns a Promise, any rejection (e.g., missing private key or failing protocol fetch) bubbles up as an unhandled rejection, leaving the proving store half-initialized and making downstream UI appear stuck. Please await both branches (and the fallback in Line 90) so failures surface through the surrounding try/catch and the store can be safely reset.

-        init(selfClient, 'register');
+        await init(selfClient, 'register');
       } else {
-        init(selfClient, 'dsc');
+        await init(selfClient, 'dsc');
       }
     } catch (error) {
-      console.error('Error loading selected document:', error);
-      init(selfClient, 'dsc');
+      console.error('Error loading selected document:', error instanceof Error ? error.message : 'unknown');
+      await init(selfClient, 'dsc');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
init(selfClient, 'register');
} else {
init(selfClient, 'dsc');
}
} catch (error) {
console.error('Error loading selected document:', error);
init(selfClient, 'dsc');
}
await init(selfClient, 'register');
} else {
await init(selfClient, 'dsc');
}
} catch (error) {
console.error(
'Error loading selected document:',
error instanceof Error ? error.message : 'unknown'
);
await init(selfClient, 'dsc');
}
🤖 Prompt for AI Agents
In packages/mobile-sdk-alpha/src/context.tsx around lines 84 to 91, the calls to
init(selfClient, 'register') and init(selfClient, 'dsc') (including the fallback
in the catch) are not awaited even though init returns a Promise; change those
three calls to await init(...) so any rejection is caught by the surrounding
try/catch and the store can be reset safely; ensure the enclosing function is
async (or convert it to async) so awaiting is valid.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this code has only been moved, can be tackled separately (if needed)

Copy link
Contributor

Choose a reason for hiding this comment

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

@shazarre, understood! Since this is moved code, it makes sense to keep the refactoring focused and address the async handling in a follow-up if needed. Thanks for clarifying! 👍

Comment on lines +88 to +90
} catch (error) {
console.error('Error loading selected document:', error);
init(selfClient, 'dsc');
Copy link
Contributor

@coderabbitai coderabbitai bot Oct 1, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Avoid logging PII
Line 89 logs the full error object from loadSelectedDocument. That error can include passport metadata or other sensitive identifiers, which would then land in device logs—clear violation of our no-PII logging rule for SDK code. Please log only a sanitized message (e.g., the generic string or a whitelisted code) instead of the entire object.

-      console.error('Error loading selected document:', error);
+      console.error('Error loading selected document');
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error) {
console.error('Error loading selected document:', error);
init(selfClient, 'dsc');
} catch (error) {
console.error('Error loading selected document');
init(selfClient, 'dsc');
}
🤖 Prompt for AI Agents
In packages/mobile-sdk-alpha/src/context.tsx around lines 88 to 90, the catch
block currently calls console.error with the full error object which may contain
PII; change this to log only a sanitized message or whitelisted error code (for
example: console.error('Error loading selected document: <LOAD_DOC_ERROR>') or
use a telemetry call that records a non-PII error code), and do not include the
error object or stack in logs; keep the existing init(selfClient, 'dsc') call
unchanged so recovery still runs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this code has only been moved, can be tackled separately

Copy link
Contributor

Choose a reason for hiding this comment

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

@shazarre, understood—I'll defer this for now since it's pre-existing code. Would you like me to open a follow-up issue to track the PII logging cleanup separately?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
app/src/screens/prove/ConfirmBelongingScreen.tsx (1)

48-50: Haptic feedback is present

The notificationSuccess() haptic feedback fires on component mount via the useEffect with empty dependencies. The past review concern appears to be resolved or was based on outdated code.

🧹 Nitpick comments (1)
app/src/screens/prove/ConfirmBelongingScreen.tsx (1)

117-130: Consider extracting inline style object

The inline style object at line 125 {{ flexDirection: 'row', alignItems: 'center' }} creates a new reference on each render. While React Native optimizes this, extracting it to a constant would be slightly more performant.

const loadingContainerStyle = { flexDirection: 'row' as const, alignItems: 'center' as const };

// Then in JSX:
<View style={loadingContainerStyle}>
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db9a9b6 and 3910abc.

📒 Files selected for processing (3)
  • app/src/screens/prove/ConfirmBelongingScreen.tsx (2 hunks)
  • packages/mobile-sdk-alpha/src/context.tsx (2 hunks)
  • packages/mobile-sdk-alpha/src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/mobile-sdk-alpha/src/context.tsx
🧰 Additional context used
📓 Path-based instructions (6)
packages/mobile-sdk-alpha/src/index.ts

📄 CodeRabbit inference engine (.cursor/rules/mobile-sdk-migration.mdc)

Re-export new SDK modules via packages/mobile-sdk-alpha/src/index.ts

Files:

  • packages/mobile-sdk-alpha/src/index.ts
packages/mobile-sdk-alpha/**/*.{ts,tsx}

📄 CodeRabbit inference engine (packages/mobile-sdk-alpha/AGENTS.md)

packages/mobile-sdk-alpha/**/*.{ts,tsx}: Use strict TypeScript type checking across the codebase
Follow ESLint TypeScript-specific rules
Avoid introducing circular dependencies

Files:

  • packages/mobile-sdk-alpha/src/index.ts
**/*.{js,ts,tsx,jsx,sol,nr}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{js,ts,tsx,jsx,sol,nr}: NEVER log sensitive data including PII (names, DOB, passport numbers, addresses), credentials, tokens, API keys, private keys, or session identifiers.
ALWAYS redact/mask sensitive fields in logs using consistent patterns (e.g., ***-***-1234 for passport numbers, J*** D*** for names).

Files:

  • packages/mobile-sdk-alpha/src/index.ts
  • app/src/screens/prove/ConfirmBelongingScreen.tsx
packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

packages/mobile-sdk-alpha/**/*.{ts,tsx,js,jsx}: Review alpha mobile SDK code for:

  • API consistency with core SDK
  • Platform-neutral abstractions
  • Performance considerations
  • Clear experimental notes or TODOs

Files:

  • packages/mobile-sdk-alpha/src/index.ts
app/**/*.{ts,tsx}

📄 CodeRabbit inference engine (app/AGENTS.md)

Type checking must pass before PRs (yarn types)

Files:

  • app/src/screens/prove/ConfirmBelongingScreen.tsx
app/src/**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

app/src/**/*.{ts,tsx,js,jsx}: Review React Native TypeScript code for:

  • Component architecture and reusability
  • State management patterns
  • Performance optimizations
  • TypeScript type safety
  • React hooks usage and dependencies
  • Navigation patterns

Files:

  • app/src/screens/prove/ConfirmBelongingScreen.tsx
🧠 Learnings (1)
📚 Learning: 2025-08-26T14:49:11.190Z
Learnt from: shazarre
PR: selfxyz/self#936
File: app/src/screens/passport/PassportNFCScanScreen.tsx:28-31
Timestamp: 2025-08-26T14:49:11.190Z
Learning: SelfClientProvider is wrapped in app/App.tsx, providing context for useSelfClient() hook usage throughout the React Native app navigation stacks.

Applied to files:

  • packages/mobile-sdk-alpha/src/index.ts
🧬 Code graph analysis (1)
app/src/screens/prove/ConfirmBelongingScreen.tsx (1)
packages/mobile-sdk-alpha/src/context.tsx (1)
  • usePrepareDocumentProof (60-87)
🪛 GitHub Actions: Web CI
app/src/screens/prove/ConfirmBelongingScreen.tsx

[error] 12-12: Build failed: 'usePrepareDocumentProof' is not exported by '@selfxyz/mobile-sdk-alpha'; import may be broken due to export mismatch. Check package exports or update the import.

⏰ Context from checks skipped due to timeout of 300000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Cursor Bugbot
  • GitHub Check: Cursor Bugbot
  • GitHub Check: build-deps
  • GitHub Check: e2e-ios
  • GitHub Check: analyze-android
  • GitHub Check: analyze-ios
🔇 Additional comments (4)
app/src/screens/prove/ConfirmBelongingScreen.tsx (3)

11-14: LGTM! Clean import structure

The import correctly includes the new usePrepareDocumentProof hook from the SDK, following the established pattern.


39-46: LGTM! Proper hook integration

The refactor correctly replaces direct useProvingStore access with the high-level usePrepareDocumentProof hook, simplifying the component and delegating initialization to the SDK.


52-87: LGTM! Robust error handling and security-conscious

The handler properly manages async operations, notification permissions, and error states. No sensitive data is logged (only generic error messages), adhering to security guidelines.

packages/mobile-sdk-alpha/src/index.ts (1)

71-71: Export correctly declared
usePrepareDocumentProof is exported in packages/mobile-sdk-alpha/src/context.tsx (line 60), so the re-export in src/index.ts is valid.

Likely an incorrect or invalid review comment.

initializeProving();
}, [init, selfClient]);

return { setUserConfirmed, isReadyToProve };
Copy link

Choose a reason for hiding this comment

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

Bug: Stale Closures and Missing Dependencies

The useEffect in usePrepareDocumentProof re-initializes excessively due to init (from a Zustand selector) changing on every render, and omits loadSelectedDocument from its dependencies, potentially causing stale closures. Separately, the returned setUserConfirmed function expects a selfClient argument but is called without it, leading to incorrect behavior.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

you trippin.

@aaronmgdr aaronmgdr merged commit 3b14f09 into dev Oct 1, 2025
29 checks passed
@aaronmgdr aaronmgdr deleted the shazarre/poc_high_level_hook branch October 1, 2025 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants