Skip to content

Comments

deprecated addContext and replaced it with setContext#57

Merged
Sajjad21990 merged 2 commits intomainfrom
feat/deprecateAddContext
Nov 5, 2025
Merged

deprecated addContext and replaced it with setContext#57
Sajjad21990 merged 2 commits intomainfrom
feat/deprecateAddContext

Conversation

@Sajjad21990
Copy link
Contributor

@Sajjad21990 Sajjad21990 commented Nov 5, 2025

Description

Deprecate addContext method and replaced it with setContext

Testing (ignore for documentation update)

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Checklist:

Additional Notes:

Summary by CodeRabbit

  • Documentation

    • Updated examples to show a configurable initialization pattern (init(..., { options })) and modernized JavaScript styling for consistency.
  • API Updates

    • Renamed context method to a clearer name and added a deprecated alias to preserve compatibility.
    • Improved error messages for context operations for clearer troubleshooting.
  • Chores

    • Package version bumped to 4.5.2.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai
Copy link

coderabbitai bot commented Nov 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The PR renames the public context API from addContext() to setContext() (keeps a deprecated addContext alias), renames AddContextErrorSetContextError, updates README init examples to accept an options object, bumps package version, and applies minor formatting tweaks.

Changes

Cohort / File(s) Summary
API & Errors
src/Reclaim.ts, src/utils/errors.ts
Replaced addContext(address, message) with setContext(address, message) and added a deprecated addContext alias that forwards to setContext; renamed exported error type AddContextErrorSetContextError; updated error messages and imports accordingly.
Docs / Usage Examples
README.md
Updated examples to call ReclaimProofRequest.init(APP_ID, APP_SECRET, PROVIDER_ID, { ...options }) (adds options object such as useBrowserExtension, extensionID, useAppClip, log); standardized string quoting, semicolons, and minor JS modernizations in code samples.
Example App Formatting
example/src/app/page.tsx
Replaced deprecated addContext usage with setContext; whitespace/JSX/formatting adjustments only.
Metadata
package.json
Version bumped from 4.5.1 → 4.5.2.

Sequence Diagram(s)

sequenceDiagram
    participant App as Consumer App
    participant SDK as ReclaimProofRequest
    participant Err as Error type

    note over App,SDK `#E6F7FF`: New public API flow (setContext)
    App->>SDK: setContext(address, message)
    alt success
        SDK-->>App: resolve / success
    else failure
        SDK-->>Err: throw SetContextError(inner)
        Err-->>App: propagated error
    end

    note over App,SDK `#FFF4E6`: Deprecated alias
    App->>SDK: addContext(address, message) [deprecated]
    SDK-->>SDK: forward to setContext(address, message)
    SDK-->>App: same result as setContext
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas to focus in review:
    • Confirm addContext deprecated alias unconditionally delegates to setContext and preserves behavior (arguments, return type, thrown errors).
    • Verify all imports/usages updated to use SetContextError and no remaining references to AddContextError.
    • Ensure README examples' new init(..., { options }) shape matches actual init implementation (option names/types).
    • Check example app replacement of addContextsetContext is correct and consistent.

Possibly related PRs

Suggested reviewers

  • Kushal7788
  • kryptocodes

Poem

🐇 I hopped from old to new with zest,

setContext now holds the nest,
addContext still lends a paw,
Errors renamed to fit the law,
Docs gleam bright — a rabbit's rest ✨

Pre-merge checks and finishing touches

✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly summarizes the main change: deprecating addContext method and replacing it with setContext, which aligns with the primary objective of this pull request.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 008ad02 and d3642c1.

⛔ Files ignored due to path filters (1)
  • example/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • example/src/app/page.tsx (9 hunks)
  • package.json (1 hunks)

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.

Copy link

@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

🧹 Nitpick comments (1)
README.md (1)

295-301: Documentation updated to show the new setContext API with deprecation notice.

The README correctly documents the new setContext method and marks addContext as deprecated. However, consider adding information about:

  • When addContext will be removed (version/timeline)
  • Migration steps for existing users
  • Whether there are any behavioral differences between the two methods

Consider adding a migration note like:

 1. **Adding Context**:
    You can add context to your proof request, which can be useful for providing additional information:

    ```javascript
    reclaimProofRequest.setContext("0x00000000000", "Example context message");

-   // deprecated method: use setContext instead
+   // @deprecated since v4.5.0, will be removed in v5.0.0 - use setContext instead
    reclaimProofRequest.addContext("0x00000000000", "Example context message");
    ```
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0c22c and 008ad02.

📒 Files selected for processing (4)
  • README.md (13 hunks)
  • example/src/app/page.tsx (9 hunks)
  • src/Reclaim.ts (7 hunks)
  • src/utils/errors.ts (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-13T08:38:17.201Z
Learnt from: ChinmayMhatre
Repo: reclaimprotocol/reclaim-js-sdk PR: 54
File: example/src/app/debug/page.tsx:53-62
Timestamp: 2025-09-13T08:38:17.201Z
Learning: Device detection caching in the Reclaim SDK is intentionally designed to maintain consistent device type (mobile vs desktop) even when screen dimensions change, such as with fold phones. This prevents device type oscillation during folding/unfolding operations.

Applied to files:

  • README.md
🧬 Code graph analysis (2)
example/src/app/page.tsx (1)
src/utils/interfaces.ts (1)
  • Proof (2-10)
src/Reclaim.ts (4)
src/utils/interfaces.ts (1)
  • Proof (2-10)
src/utils/validationUtils.ts (1)
  • validateFunctionParams (15-30)
src/utils/logger.ts (1)
  • error (46-48)
src/utils/errors.ts (1)
  • SetContextError (35-35)
🔇 Additional comments (9)
src/utils/errors.ts (2)

5-8: Minor formatting adjustment in error message construction.

The formatting changes improve readability without affecting functionality.


35-35: Error type renamed from AddContextError to SetContextError.

This change aligns with the new setContext method naming. The breaking change affects external code that directly imports or catches AddContextError. The deprecated addContext method at line 434-436 of src/Reclaim.ts maintains backward compatibility for method calls, but not for the error type itself. No remaining references to AddContextError exist in the codebase.

example/src/app/page.tsx (2)

45-48: Documentation updated to reflect the new setContext API.

The comments correctly demonstrate the new setContext method and mark addContext as deprecated. This provides clear guidance for developers using the example code.


75-255: Formatting improvements enhance code readability.

The additional whitespace and line breaks improve the visual structure of the JSX code without affecting functionality.

README.md (1)

134-529: Formatting improvements enhance documentation readability.

The additional whitespace throughout the document improves visual organization and makes code examples easier to follow.

src/Reclaim.ts (4)

22-22: Import updated to use SetContextError.

The import change is necessary and correct, aligning with the error type rename in src/utils/errors.ts.


47-51: Parameter naming consistency in verifyProof.

The formatting adjustment maintains consistent parameter usage throughout the recursive verification flow.


420-431: Method renamed from addContext to setContext with updated error handling.

The method is correctly renamed and uses the new SetContextError type with updated error messages. The implementation logic remains unchanged.


210-819: Minor formatting adjustments improve code readability.

The whitespace and line break adjustments throughout the file are cosmetic improvements that don't affect functionality.

Comment on lines +433 to +436
// deprecated method: use setContext instead
addContext(address: string, message: string): void {
this.setContext(address, message);
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Add JSDoc deprecation annotation to the deprecated addContext method.

While the deprecated addContext alias correctly forwards to setContext for backward compatibility, it lacks a JSDoc @deprecated annotation. This annotation would enable IDE warnings and help developers discover the deprecation more easily.

Apply this diff to add proper deprecation documentation:

+    /**
+     * @deprecated Use setContext() instead. This method will be removed in a future version.
+     */
     addContext(address: string, message: string): void {
         this.setContext(address, message);
     }
📝 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
// deprecated method: use setContext instead
addContext(address: string, message: string): void {
this.setContext(address, message);
}
// deprecated method: use setContext instead
/**
* @deprecated Use setContext() instead. This method will be removed in a future version.
*/
addContext(address: string, message: string): void {
this.setContext(address, message);
}
🤖 Prompt for AI Agents
In src/Reclaim.ts around lines 433 to 436, the deprecated addContext method is
missing a JSDoc deprecation annotation; add a JSDoc comment immediately above
the method with an @deprecated tag indicating it is deprecated in favor of
setContext (eg. "@deprecated Use setContext(address, message) instead."),
optionally include the removal version or migration note, and keep the method
body unchanged so it continues to forward to setContext for backward
compatibility.

@Sajjad21990 Sajjad21990 merged commit 0f1d1c6 into main Nov 5, 2025
1 check was pending
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