-
Notifications
You must be signed in to change notification settings - Fork 180
Read document catalog from selfClient #936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
b49e2c9
9806373
1a371e6
95e8e88
65cebe1
0eb0514
bbc24cd
dd117ff
167a172
aef32dc
55b22e1
77f8766
231e42a
92ce174
3e7c0fa
d0f1d92
974f76b
f76f9e2
ba6a315
f856ddf
8293f92
2c36f32
65c1d74
5b9601c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,20 @@ import type { PassportMetadata } from './passports/passport_parsing/parsePasspor | |||||||||||||||||||||||||||||||||
| export type DocumentCategory = 'passport' | 'id_card'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export type DocumentType = 'passport' | 'id_card' | 'mock_passport' | 'mock_id_card'; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export interface DocumentCatalog { | ||||||||||||||||||||||||||||||||||
| documents: DocumentMetadata[]; | ||||||||||||||||||||||||||||||||||
| selectedDocumentId?: string; // This is now a contentHash | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| export interface DocumentMetadata { | ||||||||||||||||||||||||||||||||||
| id: string; // contentHash as ID for deduplication | ||||||||||||||||||||||||||||||||||
| documentType: string; // passport, mock_passport, id_card, etc. | ||||||||||||||||||||||||||||||||||
| documentCategory: DocumentCategory; // passport, id_card, aadhaar | ||||||||||||||||||||||||||||||||||
| data: string; // DG1/MRZ data for passports/IDs, relevant data for aadhaar | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+16
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainInconsistent category usage (‘aadhaar’) vs. declared DocumentCategory union Comments and downstream code (ManageDocumentsScreen.extractCountryFromData) handle 'aadhaar', but DocumentCategory only allows 'passport' | 'id_card'. This mismatch will lead to unreachable branches and ad-hoc string typing elsewhere. Two options:
Run this to locate all usages and scope the change: If you decide to include 'aadhaar', add it in the shared union and update comments accordingly. 🏁 Script executed: #!/bin/bash
rg -nP -C2 "\baadhaar\b|\\bDocumentCategory\\b" --type=ts --type=tsxLength of output: 96 I’ll re-run the search across all 🏁 Script executed: #!/bin/bash
# Search for DocumentCategory usages and aadhaar occurrences in TS/TSX files
rg -nP -C2 "\baadhaar\b|\bDocumentCategory\b" -g "*.ts" -g "*.tsx"
# Locate the definition of the DocumentCategory union
rg -nP "type\s+DocumentCategory\b" -g "*.ts"Length of output: 13827 Add ‘aadhaar’ to the DocumentCategory union to match its usage The codebase is already treating “aadhaar” as a first-class documentCategory (inference logic, screen branches, proving inputs, etc.), but the shared type only allows ‘passport’ or ‘id_card’. This mismatch forces pervasive casts ( Required refactor:
This change is critical to maintain type safety and prevent runtime surprises. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
| mock: boolean; // whether this is a mock document | ||||||||||||||||||||||||||||||||||
| isRegistered?: boolean; // whether the document is registered onChain | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+20
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Type safety: use the existing DocumentType instead of string for documentType documentType is declared as string even though DocumentType is defined in this module. This weakens compile-time guarantees and risks drift with getDisplayName and other consumers. Apply this diff: export interface DocumentMetadata {
id: string; // contentHash as ID for deduplication
- documentType: string; // passport, mock_passport, id_card, etc.
+ documentType: DocumentType; // passport, mock_passport, id_card, etc.
documentCategory: DocumentCategory; // passport, id_card, aadhaar
data: string; // DG1/MRZ data for passports/IDs, relevant data for aadhaar
mock: boolean; // whether this is a mock document
isRegistered?: boolean; // whether the document is registered onChain
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| export type PassportData = { | ||||||||||||||||||||||||||||||||||
| mrz: string; | ||||||||||||||||||||||||||||||||||
| dg1Hash?: number[]; | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.