Skip to content

Conversation

@kevinsslin
Copy link
Collaborator

@kevinsslin kevinsslin commented Jul 28, 2025

Clean SDK Parameters

This PR cleans up the Self SDK API with three key improvements for better developer experience.

⚠️ Breaking Changes

This PR contains BREAKING CHANGES that require code updates:

1. SelfBackendVerifier Constructor

// ❌ Before (will break)
new SelfBackendVerifier(scope, endpoint, false, allowedIds, configStorage, userIdType)
new SelfBackendVerifier(scope, endpoint, true, allowedIds, configStorage, userIdType)

// ✅ After
new SelfBackendVerifier(scope, endpoint, 'mainnet', allowedIds, configStorage, userIdType)
new SelfBackendVerifier(scope, endpoint, 'testnet', allowedIds, configStorage, userIdType)

2. SelfApp Interface

// ❌ Before (will break)
const app = new SelfAppBuilder({
  logoBase64: 'data:image/png;base64,iVBORw0KGgoAAAANS...',
  version: 2, // Required
}).build();

// ✅ After  
const app = new SelfAppBuilder({
  logoUrl: 'https://example.com/logo.png',
  // version: 2 auto-default
}).build();

🔄 Migration Guide

Backend Verifier Migration

Find and replace in your codebase:

// Pattern 1: Mainnet usage
// Before
const verifier = new SelfBackendVerifier(
  'my-scope',
  'https://api.example.com/verify', 
  false, // ← Replace this
  allowedIds,
  configStorage,
  'uuid'
);

// After
const verifier = new SelfBackendVerifier(
  'my-scope',
  'https://api.example.com/verify',
  'mainnet', // ← With this
  allowedIds,
  configStorage,
  'uuid'
);
// Pattern 2: Testnet usage
// Before
const verifier = new SelfBackendVerifier(
  'my-scope',
  'https://api.example.com/verify',
  true, // ← Replace this
  allowedIds,
  configStorage,
  'uuid'
);

// After
const verifier = new SelfBackendVerifier(
  'my-scope',
  'https://api.example.com/verify',
  'testnet', // ← With this
  allowedIds,
  configStorage,
  'uuid'
);

App Builder Migration

Update your SelfAppBuilder calls:

// Before
const selfApp = new SelfAppBuilder({
  appName: 'My App',
  scope: 'my-scope',
  endpoint: 'https://api.example.com/verify',
  logoBase64: 'data:image/png;base64,iVBORw0KGgoAAAANS...', // ← Remove this
  version: 2, // ← Remove this (now auto-default)
  userId: 'user-123',
  disclosures: { name: true, age: true }
}).build();

// After
const selfApp = new SelfAppBuilder({
  appName: 'My App',
  scope: 'my-scope', 
  endpoint: 'https://api.example.com/verify',
  logoUrl: 'https://cdn.example.com/logo.png', // ← Add this
  // version: 2 automatically set
  userId: 'user-123',
  disclosures: { name: true, age: true }
}).build();

Logo Migration Tips

// ✅ Good: Direct URL
logoUrl: 'https://example.com/logo.png'

// ✅ Good: CDN URL  
logoUrl: 'https://cdn.example.com/assets/logo.png'

// ❌ Bad: Base64 (no longer supported)
logoBase64: 'data:image/png;base64,iVBORw0KGgoAAAANS...'

// ❌ Bad: Relative path (won't work)
logoUrl: '/assets/logo.png'

TypeScript Updates

If you're using TypeScript, update your type imports:

// Add this import for type safety
import type { Network } from '@selfxyz/core';

// Use in your code
const network: Network = 'mainnet'; // or 'testnet'

🎯 Why These Changes

  • logoUrl: URLs are standard web practice, better performance (no large base64 in QR codes)
  • network: Clear intent vs confusing boolean, easier to extend with new networks
  • Auto version: Remove boilerplate for 99% of use cases

📱 Mobile App Impact

Mobile app users: No action required. Existing app installations continue working.

Technical detail: We maintained database compatibility by keeping the logoBase64 column but storing URL values in it. This avoids forcing app updates while modernizing the SDK interface.

✅ Validation

  • Builds: All packages compile successfully
  • Types: TypeScript checks pass
  • Tests: All existing tests updated and passing
  • Compatibility: Existing mobile app data preserved

Test your changes:

yarn build    # Verify compilation
yarn types    # Check TypeScript
yarn lint     # Code style

Summary by CodeRabbit

  • New Features

    • Added comprehensive documentation outlining project structure, development commands, architecture, testing, and CI requirements.
  • Refactor

    • Replaced all usage of base64-encoded logo strings (logoBase64) with logo URLs (logoUrl) across the app, SDK, and documentation.
    • Updated interfaces, components, and database handling to use logoUrl instead of logoBase64.
    • Modified network parameter handling in SDK from boolean flag to explicit 'mainnet' | 'testnet' values.
  • Documentation

    • Updated SDK and QR code documentation to reflect the new logoUrl property and revised usage examples.
    • Clarified configuration and parameter descriptions for end-users.
  • Tests

    • Updated test cases to use logoUrl in place of logoBase64 for logo handling.

…ed components

- Updated SelfApp interface to use logoUrl instead of logoBase64.
- Modified SelfAppBuilder and README files to reflect the change in logo property.
- Adjusted SelfBackendVerifier to accept network type instead of mockPassport.
- Updated related documentation and examples to ensure consistency across the codebase.
- Change mockPassport boolean parameter to network ('mainnet' | 'testnet')
- Update RPC URL logic to use network-specific endpoints
- Export Network type for type safety
- BREAKING CHANGE: SelfBackendVerifier constructor API updated
- Replace logoBase64 with logoUrl in SelfApp interface (PNG URLs only)
- Set version 2 as automatic default in SelfAppBuilder
- Update constructor to use explicit assignment instead of spread
- BREAKING CHANGE: SelfApp interface now uses logoUrl instead of logoBase64
- Update ProofHistory interface to use logoUrl instead of logoBase64
- Maintain database backward compatibility (logoBase64 column stores logoUrl)
- Add type casting for database row mapping to handle schema transition
- Update proof insertion logic to use new logoUrl property
- Update ProveScreen to use logoUrl from selectedApp
- Update ProofHistoryScreen logo rendering logic for logoUrl
- Update ProofHistoryDetailScreen logo source handling for logoUrl
- Maintain compatibility for both URL and base64 logo formats in UI
- Replace logoBase64 with logoUrl in database test mock data
- Update proofHistoryStore test fixtures to use logoUrl
- Update proving machine test to use logoUrl in selfApp mock
- Use realistic URL examples instead of base64 strings in tests
- Update SelfBackendVerifier example to use 'mainnet' string instead of false
- Add clear comment explaining network parameter options
- Ensure documentation reflects the new network parameter API
- Add comprehensive developer documentation for Claude Code AI assistant
- Include monorepo structure, development commands, and architecture patterns
- Document testing strategies and key files for understanding the codebase
- Provide guidance for AI-assisted development workflows
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 28, 2025

Walkthrough

This update replaces all usage of the logoBase64 property with logoUrl across the codebase, affecting interfaces, database storage, business logic, and documentation. It also introduces a new network parameter for SDK configuration, replacing the previous mockPassport boolean. Documentation and tests are updated to reflect these changes, and a new repository guidance document is added.

Changes

Cohort / File(s) Change Summary
Documentation Updates
CLAUDE.md
sdk/core/README.md
sdk/qrcode/README.md
Added CLAUDE.md for AI guidance. Updated documentation to replace logoBase64 with logoUrl and clarify usage of network instead of mockPassport in SDK examples.
Proof Logo Refactor (App Logic & UI)
app/src/screens/home/ProofHistoryDetailScreen.tsx
app/src/screens/home/ProofHistoryScreen.tsx
app/src/screens/prove/ProveScreen.tsx
Replaced all logic and references from logoBase64 to logoUrl for proof logo handling in React Native screens. Adjusted logic to support only URLs, removing base64 support in some areas.
Database Schema & Store
app/src/stores/database.ts
app/src/stores/proof-types.ts
app/src/stores/proofHistoryStore.ts
Updated schema comments and data handling to store and retrieve logoUrl in the logoBase64 column for backward compatibility. Refactored types and store logic to use logoUrl property.
Tests (App)
app/tests/src/stores/database.test.ts
app/tests/src/stores/proofHistoryStore.test.ts
app/tests/utils/proving/provingMachine.generatePayload.test.ts
Updated test cases and mocks to use logoUrl instead of logoBase64 for proof logo data.
SDK: SelfBackendVerifier & Exports
sdk/core/src/SelfBackendVerifier.ts
sdk/core/src/index.ts
Replaced mockPassport boolean with `network: 'mainnet'
SDK: Types & Utilities
common/src/utils/appType.ts
sdk/qrcode/utils/websocket.ts
Changed interface properties from logoBase64 to logoUrl in SelfApp and WebAppInfo. Refactored builder logic for explicit config assignment.

Sequence Diagram(s)

sequenceDiagram
    participant AppScreen as React Native Screen
    participant Store as ProofHistoryStore
    participant DB as SQLite DB

    AppScreen->>Store: addProof({logoUrl, ...})
    Store->>DB: insertProof({logoUrl → logoBase64 column, ...})
    DB-->>Store: Insert result
    Store-->>AppScreen: Updated proof history (logoUrl)
    AppScreen->>AppScreen: Render logo using logoUrl (only supports URLs)
Loading
sequenceDiagram
    participant SDKUser as Developer
    participant SDK as SelfBackendVerifier

    SDKUser->>SDK: new SelfBackendVerifier(network: 'mainnet' | 'testnet')
    SDK->>SDK: Select RPC URL & contract address based on network
    SDK-->>SDKUser: Instance ready with correct endpoints
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Suggested labels

codex

Suggested reviewers

  • motemotech
  • remicolin

Poem

A logo once base64, now takes a new route,
As URLs glide in, leaving old bytes out.
The SDK speaks of networks, mainnet or test,
And docs now explain it, so users aren’t stressed.
Code and tests in harmony,
A modernized repo—ship it with glee! 🚀

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3d928fe and 0bc2305.

📒 Files selected for processing (2)
  • CLAUDE.md (1 hunks)
  • sdk/qrcode/README.md (2 hunks)
✅ Files skipped from review due to trivial changes (2)
  • sdk/qrcode/README.md
  • CLAUDE.md
⏰ 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). (1)
  • GitHub Check: run_circuit_tests
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sel-531

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kevinsslin kevinsslin changed the base branch from main to dev July 28, 2025 01:12
@kevinsslin kevinsslin self-assigned this Jul 28, 2025
@kevinsslin kevinsslin changed the title Clean SDK parameters: logoBase64 → logoUrl, mockPassport → network, version 2 default SEL-531: Clean the parameters in the Self SDK Jul 28, 2025
- Fixed QRCode workspace formatting issue that was causing lint failures
- Added comprehensive CI/CD requirements section to CLAUDE.md covering:
  - All GitHub Actions workflows (general-checks, app, circuits, contracts)
  - Security scanning setup (Gitleaks, GitGuardian)
  - Pre-commit hooks configuration
  - Environment requirements for different workspaces
- Added linting section explaining ESLint warnings vs errors policy
- Updated QRCode README with proper table formatting
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: 1

🔭 Outside diff range comments (3)
sdk/qrcode/README.md (1)

1-1: Apply Prettier formatting to README

Prettier flagged code style issues in sdk/qrcode/README.md. To keep our docs consistent and unblock the CI pipeline, please run:

npx prettier --write sdk/qrcode/README.md

• File affected: sdk/qrcode/README.md

app/tests/src/stores/proofHistoryStore.test.ts (2)

128-148: Inconsistent test coverage: Some test cases missing logoUrl property.

Several test cases create mock proof objects without the logoUrl property, while others include it. This inconsistency could mask potential issues with logo handling when the property is undefined.

Consider adding logoUrl to all test cases for consistency:

 const mockProof = {
   appName: 'TestApp',
   sessionId: 'session-123',
   userId: 'user-456',
   userIdType: 'uuid',
   endpointType: 'celo',
   status: ProofStatus.PENDING,
   disclosures: '{"test": "data"}',
+  logoUrl: 'https://example.com/logo.png',
 } as const;

Also applies to: 191-230, 282-312


27-28: Address TypeScript any usage to improve type safety.

The any type usage flagged by ESLint reduces type safety. Consider creating proper type interfaces for the mocked database and socket objects.

-const mockDatabase = database as any;
-const mockIo = io as any;
+const mockDatabase = database as jest.Mocked<typeof database>;
+const mockIo = io as jest.MockedFunction<typeof io>;
🧹 Nitpick comments (4)
CLAUDE.md (3)

1-4: Consider relocating or cross-linking this guide to established docs sections

Dropping a standalone CLAUDE.md in the repo root risks discoverability issues—contributors will likely look for CONTRIBUTING.md, DEVELOPMENT.md, or the main README first. Either:

-# CLAUDE.md
+# DEVELOPMENT.md   <!-- or merge into CONTRIBUTING.md -->

or explicitly reference it from the README/CONTRIBUTING to avoid bit-rot.


20-27: Document required Node & Yarn versions to avoid build pain

The command list assumes the correct toolchain is already installed, but yarn@4 PnP and Circom tooling are notoriously version-sensitive. Add a short “Prerequisites” bullet right above the command table, e.g.:

+### Prerequisites
+- Node.js ≥ 18.17 (LTS)  
+- Yarn 4.6.0 (Plug’n’Play enabled)  
+- Rust toolchain ≥ 1.70 (for circom_tester)  

This heads off common “cannot find module” and native-addon build errors on fresh clones.


120-131: Unify formatting commands to reduce cognitive overhead

Two different script names (fmt vs format) for essentially the same Prettier pass is easy to forget and causes CI churn. Prefer one canonical script and make the other an alias:

-### App-specific formatting:
-cd app && yarn fmt:fix
-cd app && yarn fmt
+### Formatting (all workspaces):
+yarn format:fix   # runs prettier on root & app via workspaces
+yarn format       # check mode

Then wire app/package.json:

 "scripts": {
-  "fmt": "prettier --check .",
-  "fmt:fix": "prettier --write ."
+  "format": "prettier --check .",
+  "format:fix": "prettier --write ."
 }

A single mental model keeps new contributors from tripping CI.

app/tests/utils/proving/provingMachine.generatePayload.test.ts (1)

10-133: Address ESLint warning for explicit 'any' usage.

The pipeline flagged an ESLint warning about "Unexpected any" usage. Consider adding proper TypeScript types to improve type safety in test mocks.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4721d12 and 3d928fe.

📒 Files selected for processing (16)
  • CLAUDE.md (1 hunks)
  • app/src/screens/home/ProofHistoryDetailScreen.tsx (1 hunks)
  • app/src/screens/home/ProofHistoryScreen.tsx (1 hunks)
  • app/src/screens/prove/ProveScreen.tsx (2 hunks)
  • app/src/stores/database.ts (2 hunks)
  • app/src/stores/proof-types.ts (1 hunks)
  • app/src/stores/proofHistoryStore.ts (2 hunks)
  • app/tests/src/stores/database.test.ts (3 hunks)
  • app/tests/src/stores/proofHistoryStore.test.ts (3 hunks)
  • app/tests/utils/proving/provingMachine.generatePayload.test.ts (1 hunks)
  • common/src/utils/appType.ts (2 hunks)
  • sdk/core/README.md (3 hunks)
  • sdk/core/src/SelfBackendVerifier.ts (2 hunks)
  • sdk/core/src/index.ts (1 hunks)
  • sdk/qrcode/README.md (2 hunks)
  • sdk/qrcode/utils/websocket.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{test,spec}.{ts,js,tsx,jsx}

⚙️ CodeRabbit Configuration File

**/*.{test,spec}.{ts,js,tsx,jsx}: Review test files for:

  • Test coverage completeness
  • Test case quality and edge cases
  • Mock usage appropriateness
  • Test readability and maintainability

Files:

  • app/tests/utils/proving/provingMachine.generatePayload.test.ts
  • app/tests/src/stores/proofHistoryStore.test.ts
  • app/tests/src/stores/database.test.ts
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/stores/proofHistoryStore.ts
  • app/src/stores/proof-types.ts
  • app/src/screens/home/ProofHistoryDetailScreen.tsx
  • app/src/stores/database.ts
  • app/src/screens/home/ProofHistoryScreen.tsx
  • app/src/screens/prove/ProveScreen.tsx
🪛 GitHub Actions: General Self CI
sdk/qrcode/README.md

[warning] 1-1: Prettier code style warning: Code style issues found. Run Prettier with --write to fix.

app/tests/utils/proving/provingMachine.generatePayload.test.ts

[warning] 10-133: ESLint warnings: 'Unexpected any' (@typescript-eslint/no-explicit-any).

app/src/stores/proofHistoryStore.ts

[warning] 39-200: ESLint warnings: Multiple 'Unexpected console statement' (no-console) and 'Unexpected any' (@typescript-eslint/no-explicit-any).

app/tests/src/stores/proofHistoryStore.test.ts

[warning] 27-31: ESLint warnings: 'Unexpected any' (@typescript-eslint/no-explicit-any).

app/src/stores/database.ts

[warning] 47-57: ESLint warnings: 'Unexpected console statement' (no-console).

sdk/core/README.md

[warning] 1-1: Prettier code style warning: Code style issues found. Run Prettier with --write to fix.

app/src/screens/home/ProofHistoryScreen.tsx

[warning] 297-297: ESLint warning: 'Unexpected console statement' (no-console).

app/src/screens/prove/ProveScreen.tsx

[warning] 97-122: ESLint warnings: 'Unexpected console statement' (no-console).

app/tests/src/stores/database.test.ts

[warning] 14-17: ESLint warnings: 'Unexpected any' (@typescript-eslint/no-explicit-any).

⏰ 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). (1)
  • GitHub Check: run_circuit_tests
🔇 Additional comments (28)
app/tests/utils/proving/provingMachine.generatePayload.test.ts (1)

94-94: Property rename correctly implemented in test mock.

The change from logoBase64 to logoUrl aligns with the breaking API changes. Test coverage is maintained with the updated property name.

sdk/qrcode/utils/websocket.ts (1)

8-8: Interface property rename correctly implemented.

The change from logoBase64 to logoUrl in the WebAppInfo interface is consistent with the breaking API changes and improves websocket message efficiency by using URLs instead of base64 data.

app/src/stores/proof-types.ts (1)

17-17: Type interface correctly updated for breaking change.

The property rename from logoBase64? to logoUrl? maintains the optional nature and string type while aligning with the API breaking changes. This ensures type safety across the application.

sdk/qrcode/README.md (2)

33-33: Documentation example correctly updated.

The example code properly demonstrates the new logoUrl parameter with a URL value instead of base64 data, accurately reflecting the breaking API changes.


82-82: Parameter description accurately updated.

The table correctly describes logoUrl as "URL to PNG logo" instead of the previous "Base64-encoded logo", providing clear guidance for developers.

sdk/core/src/index.ts (1)

1-1: Network type export correctly added for TypeScript support.

Adding the Network type export enables consumers to properly type the network parameter in the updated SelfBackendVerifier constructor, supporting the breaking change from boolean mockPassport to typed network parameter.

app/tests/src/stores/proofHistoryStore.test.ts (1)

66-66: LGTM! Logo property migration correctly implemented in test data.

The test data has been properly updated to use logoUrl with valid URL values. This aligns with the broader refactoring to use URLs instead of base64 strings for logos.

Also applies to: 109-109, 246-246

app/src/stores/proofHistoryStore.ts (1)

172-186: Excellent backward compatibility strategy with clear documentation.

The approach of storing logoUrl values in the existing logoBase64 database column is well-documented and maintains backward compatibility effectively. The comments clearly explain the mapping logic.

app/src/stores/database.ts (2)

108-108: Well-executed backward compatibility with clear documentation.

The database schema maintains the existing logoBase64 column name while storing URL data, with excellent documentation explaining the purpose. This approach avoids breaking changes to the mobile app database structure.

Also applies to: 131-131


120-136: Secure parameterized query implementation.

The SQL insertion uses proper parameterized queries to prevent SQL injection attacks. The parameter mapping correctly stores the logoUrl value in the logoBase64 column for backward compatibility.

app/src/screens/home/ProofHistoryDetailScreen.tsx (2)

115-131: Correct logo rendering logic with proper React hooks usage.

The logoSource memoization correctly handles the property rename from logoBase64 to logoUrl while maintaining backward compatibility for both HTTP URLs and base64 strings. The dependency array is properly updated to reflect the new property name.


120-130: Robust image source handling supports multiple formats.

The conditional logic properly handles HTTP/HTTPS URLs and base64 strings, providing flexibility for different logo formats. This maintains compatibility during the migration period.

app/src/screens/home/ProofHistoryScreen.tsx (3)

188-196: Consistent logo handling implementation across components.

The logo source logic correctly migrates from logoBase64 to logoUrl while maintaining the same backward compatibility handling for both URL and base64 formats. This ensures consistent behavior across the application.


296-299: Appropriate error handling for component rendering.

The try-catch block with console.error provides valuable debugging information when proof items fail to render, which is essential for troubleshooting data parsing issues. The graceful fallback to null prevents UI crashes.


176-302: Excellent React Native performance optimizations.

The renderItem function is properly memoized with useCallback and includes appropriate dependencies. The component handles list rendering efficiently with proper key extraction and end-reached handling.

sdk/core/README.md (3)

25-25: LGTM: Clear parameter documentation improvement.

The change from mockPassport boolean to network string parameter makes the API more self-documenting and extensible.


135-135: Documentation example updated correctly.

The example properly demonstrates the new string-based network parameter usage.


212-212: Consistent logo parameter migration.

The documentation correctly reflects the change from logoBase64 to logoUrl, aligning with the broader refactoring.

app/tests/src/stores/database.test.ts (3)

76-76: Test data correctly migrated to logoUrl.

The mock proof object properly reflects the new URL-based logo handling.


98-98: SQL parameter expectations updated consistently.

The test correctly expects logoUrl parameter in the database insertion.


144-144: Good documentation of backward compatibility approach.

The comment clearly explains that logoUrl is stored in the existing logoBase64 column, which maintains database compatibility while supporting the new URL format.

app/src/screens/prove/ProveScreen.tsx (2)

75-75: Proof history integration updated correctly.

The addProofHistory call properly uses the new logoUrl parameter.


107-127: Logo handling simplified and secured.

The new logic correctly validates HTTP/HTTPS URLs and provides helpful warnings for invalid formats. This approach is more secure and performant than base64 handling.

Consider adding additional URL validation if you need to restrict specific domains or schemes for security purposes:

// Check if the logo is a valid URL
if (
  selectedApp.logoUrl.startsWith('http://') ||
  selectedApp.logoUrl.startsWith('https://')
) {
+  // Optional: Add domain whitelist validation
+  try {
+    const url = new URL(selectedApp.logoUrl);
+    // Add any domain restrictions here if needed
+  } catch {
+    console.warn('Invalid URL format:', selectedApp.logoUrl);
+    return null;
+  }
  return { uri: selectedApp.logoUrl };
}
sdk/core/src/SelfBackendVerifier.ts (3)

27-27: Well-defined Network type for type safety.

The union type provides clear constraints and better developer experience than the previous boolean approach.


40-40: Constructor parameter improved with sensible default.

The network parameter with 'mainnet' default maintains backward compatibility while providing clearer semantics than the previous boolean mockPassport.


45-50: Network selection logic implemented correctly.

The conditional logic properly maps network types to their respective RPC URLs and contract addresses. The testnet/staging configuration is clearly separated from mainnet.

common/src/utils/appType.ts (2)

13-13: Interface correctly migrated to URL-based logos.

The change from logoBase64 to logoUrl aligns with the broader refactoring to standardize on URL-based logo handling.


92-106: Constructor refactoring improves maintainability.

The explicit field assignment approach is more readable and maintainable than the previous spread operator pattern. The version 2 default and empty string logoUrl default are appropriate choices.

This refactoring also makes it easier to track which fields have defaults and ensures all required fields are properly handled.

const totalCount = results.total_count || 0;
for (let i = 0; i < results.rows.length; i++) {
const row = results.rows[i];
const row = results.rows[i] as any; // Database row has logoBase64 column
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve type safety for database row mapping.

The any cast reduces type safety. Consider creating a proper interface for the database row structure to maintain type checking while acknowledging the column name mismatch.

+interface DatabaseRow {
+  id: string;
+  sessionId: string;
+  appName: string;
+  endpointType: string;
+  status: ProofStatus;
+  errorCode?: string;
+  errorReason?: string;
+  timestamp: number;
+  disclosures: string;
+  logoBase64?: string; // Stores logoUrl for backward compatibility
+  userId: string;
+  userIdType: string;
+}

-          const row = results.rows[i] as any; // Database row has logoBase64 column
+          const row = results.rows[i] as DatabaseRow;
📝 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
const row = results.rows[i] as any; // Database row has logoBase64 column
// At the top of the file (e.g. after imports), add:
interface DatabaseRow {
id: string;
sessionId: string;
appName: string;
endpointType: string;
status: ProofStatus;
errorCode?: string;
errorReason?: string;
timestamp: number;
disclosures: string;
logoBase64?: string; // Stores logoUrl for backward compatibility
userId: string;
userIdType: string;
}
// …later in the code, replace the `any` cast:
- const row = results.rows[i] as any; // Database row has logoBase64 column
+ const row = results.rows[i] as DatabaseRow;
🤖 Prompt for AI Agents
In app/src/stores/proofHistoryStore.ts at line 172, the database row is cast to
'any', which reduces type safety. Define a TypeScript interface representing the
expected structure of the database row, including the 'logoBase64' column, and
use this interface instead of 'any' for the row variable to improve type
checking and maintain clarity about the data shape.

Copy link
Collaborator

@remicolin remicolin left a comment

Choose a reason for hiding this comment

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

can you tell me what's happening if users update the mobile app but not the sdk?
same but reversed, what if an app is using this sdk version but users are on the previous mobile app version

@transphorm transphorm changed the title SEL-531: Clean the parameters in the Self SDK SELF-531: Clean the parameters in the Self SDK Aug 5, 2025
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