Feat/nip37 private storage relays - #644
Conversation
📝 WalkthroughWalkthroughThis PR adds support for NIP-37 private storage relays in the NDK package. A new ChangesNIP-37 Private Storage Relays
Sequence DiagramsequenceDiagram
participant Caller
participant UserRelayLists
participant Cache
participant Network
participant Signer
Caller->>UserRelayLists: getPrivateStorageRelays(forceRefresh)
UserRelayLists->>Cache: load Nip37.kPrivateStorageRelays events
alt forceRefresh or no cached event
UserRelayLists->>Network: query latest kind 10013 event
Network-->>UserRelayLists: event or null
end
alt event found
UserRelayLists->>Cache: save latest event
UserRelayLists->>Signer: decryptNip44(eventContent)
Signer-->>UserRelayLists: decrypted JSON
UserRelayLists->>UserRelayLists: parse tags, extract relay URLs
UserRelayLists-->>Caller: List<String> relay URLs
else no event or decryption failed
UserRelayLists-->>Caller: null
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@doc/usecases/user-relay-lists.md`:
- Line 13: The document contains the nonstandard term "usecase" (e.g., the
sentence "NIP-37 private storage relays are exposed through the same usecase.");
update occurrences of the token "usecase" to the standard spelling "use case"
throughout the file (for example edit the sentence to "NIP-37 private storage
relays are exposed through the same use case").
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 00e20e89-514e-4f8d-96cb-f4dd69f67d34
📒 Files selected for processing (11)
doc/usecases/user-relay-lists.mdpackages/bc_ur/lib/ur.dartpackages/ndk/lib/domain_layer/entities/nip_37.dartpackages/ndk/lib/domain_layer/usecases/user_relay_lists/user_relay_lists.dartpackages/ndk/lib/entities.dartpackages/ndk/lib/ndk.dartpackages/ndk/test/usecases/user_relay_lists/user_relay_lists_test.dartpackages/ndk_flutter/lib/data_layer/repositories/signers/amber_event_signer.dartpackages/ndk_flutter/lib/widgets/login/nostr_connect_dialog_view.dartpackages/nip07_event_signer/lib/src/nip07_event_signer_stub.dartpackages/nip07_event_signer/lib/src/nip07_event_signer_web.dart
|
|
||
| ## Private storage relays | ||
|
|
||
| NIP-37 private storage relays are exposed through the same usecase. |
There was a problem hiding this comment.
Use standard spelling: “use case”.
Replace “usecase” with “use case” to match common terminology and improve documentation readability.
🧰 Tools
🪛 LanguageTool
[grammar] ~13-~13: Ensure spelling is correct
Context: ...age relays are exposed through the same usecase. The kind 10013 event is encrypted, s...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@doc/usecases/user-relay-lists.md` at line 13, The document contains the
nonstandard term "usecase" (e.g., the sentence "NIP-37 private storage relays
are exposed through the same usecase."); update occurrences of the token
"usecase" to the standard spelling "use case" throughout the file (for example
edit the sentence to "NIP-37 private storage relays are exposed through the same
use case").
|
1-leo
left a comment
There was a problem hiding this comment.
There are some formatting changes that cause merge conflicts.
Are you using the default dart formatter or did a dart version change it?
| return other is UR && | ||
| other.type == type && | ||
| _listEquals(other.cbor, cbor); | ||
| return other is UR && other.type == type && _listEquals(other.cbor, cbor); |
There was a problem hiding this comment.
is this the default dart formatter?
There was a problem hiding this comment.
this signer is deprecated => merge from master
There was a problem hiding this comment.
I don't think we need to have this PR at all.
Using ndk.lists.getPublicList it should be possible to fetch list for kind 10013.
Just add this 10013 kind to Nip51List as kDraftRelays which is missing there, and you should be good to use it.
wdyt @1-leo ?
| @@ -0,0 +1,4 @@ | |||
| class Nip37 { | |||
| /// Relay list for private content. | |||
| static const int kPrivateStorageRelays = 10013; | |||
There was a problem hiding this comment.
This kind is not defined in nip-37, but in nip-51.
The fact that draft relays are used in nip-37 doesn't make it as the place that this kind is defined.
plan for now: |
|
=> |
This pr only add a high level api to get the private relays list
Summary by CodeRabbit
Release Notes
New Features
Documentation
Tests