Skip to content

Commit 85df5b6

Browse files
committed
Expose add relay methods for Client
1 parent e8b01f9 commit 85df5b6

File tree

5 files changed

+543
-190
lines changed

5 files changed

+543
-190
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
* Expose `NostrSigner` ([Yuki Kishimoto])
4242
* Expose `UnsignedEvent` ([Yuki Kishimoto])
4343
* Expose `EventBuilder` ([Yuki Kishimoto])
44+
* Expose add relay method for `Client` ([Yuki Kishimoto])
4445
* Expose `Client::send_event_builder` ([Yuki Kishimoto])
4546
* Expose `Client::automatic_authentication` ([Yuki Kishimoto])
4647
* Expose `Client::reset` ([Yuki Kishimoto])

lib/src/rust/api/client.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,21 @@ import 'protocol/signer.dart';
1515

1616
// Rust type: RustOpaqueMoi<flutter_rust_bridge::for_generated::RustAutoOpaqueInner<_Client>>
1717
abstract class Client implements RustOpaqueInterface {
18+
/// Add discovery relay
19+
///
20+
/// If relay already exists, this method automatically add the [`RelayServiceFlags::DISCOVERY`] flag to it and return `false`.
21+
///
22+
/// <https://github.com/nostr-protocol/nips/blob/master/65.md>
23+
Future<bool> addDiscoveryRelay({required String url});
24+
25+
/// Add read relay
26+
///
27+
/// If relay already exists, this method add the [`RelayServiceFlags::READ`] flag to it and return `false`.
28+
///
29+
/// If are set pool subscriptions, the new added relay will inherit them. Use `subscribe_to` method instead of `subscribe`,
30+
/// to avoid to set pool subscriptions.
31+
Future<bool> addReadRelay({required String url});
32+
1833
/// Add relay
1934
///
2035
/// Relays added with this method will have both `READ` and `WRITE` flags enabled.
@@ -26,6 +41,11 @@ abstract class Client implements RustOpaqueInterface {
2641
/// Connection is **NOT** automatically started with relay, remember to call `connect` method!
2742
Future<bool> addRelay({required String url});
2843

44+
/// Add write relay
45+
///
46+
/// If relay already exists, this method add the [`RelayServiceFlags::WRITE`] flag to it and return `false`.
47+
Future<bool> addWriteRelay({required String url});
48+
2949
/// Auto authenticate to relays (default: true)
3050
///
3151
/// <https://github.com/nostr-protocol/nips/blob/master/42.md>

0 commit comments

Comments
 (0)