Add Nostr Java API reference documentation#384
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull Request Overview
This pull request adds comprehensive API reference documentation for the Nostr Java library. The documentation covers the public APIs across all modules including identity management, event model, WebSocket clients, encryption, and utility functions.
Key Changes:
- Creates a new API reference document with complete coverage of public interfaces
- Provides method signatures, usage examples, and links to relevant NIPs
- Organizes content by module with clear sections for identity, events, clients, encryption, and utilities
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| public NostrIF setRelays(Map<String,String> relays) | ||
| public List<String> sendEvent(IEvent event) | ||
| public List<String> sendRequest(List<Filters> filters, String subscriptionId) | ||
| public NostrIF sign(Identity identity, ISignable signable) |
There was a problem hiding this comment.
The sign method documentation suggests it returns a NostrIF but the method signature indicates it modifies state and returns the client instance. This pattern could be confusing - consider clarifying if this is a fluent interface or if the method actually performs signing internally.
| ```java | ||
| Filters filters = new Filters(new AuthorFilter(pubKey)); | ||
| NostrIF client = NostrSpringWebSocketClient.getInstance(id); | ||
| List<String> events = client.sendRequest(filters, "sub-id"); |
There was a problem hiding this comment.
The example shows sendRequest returning List<String> events, but based on the method signature at line 97, it should return List<String> representing request IDs, not events. The variable name 'events' is misleading and should be something like 'requestIds' or 'responses'.
| List<String> events = client.sendRequest(filters, "sub-id"); | |
| List<String> requestIds = client.sendRequest(filters, "sub-id"); |
| ``` | ||
|
|
||
| ### Subscription with Filters | ||
| ```java |
There was a problem hiding this comment.
The example uses pubKey variable that is not defined in the code block. This will cause a compilation error. Either define the variable or use a placeholder like somePublicKey.
| ```java | |
| ```java | |
| PublicKey pubKey = id.getPublicKey(); |
| ```java | ||
| Filters filters = new Filters(new AuthorFilter(pubKey)); | ||
| NostrIF client = NostrSpringWebSocketClient.getInstance(id); | ||
| List<String> events = client.sendRequest(filters, "sub-id"); |
There was a problem hiding this comment.
The sendRequest method expects List<Filters> as the first parameter according to line 97, but the example passes a single Filters object. This should be Arrays.asList(filters) or List.of(filters).
| List<String> events = client.sendRequest(filters, "sub-id"); | |
| List<String> events = client.sendRequest(List.of(filters), "sub-id"); |
Summary
Testing
mvn -q verify(fails: Could not find a valid Docker environment for Testcontainers)https://chatgpt.com/codex/tasks/task_b_68a48da624788331a2de29cb22a02468