relayInformationsDocumentNip11 method
Ths method will get you RelayInformations that contains the given relayUrl
using the NIP11 implementation.
example:
final relayInformations = await Nostr.instance.relays.relayInformationsDocumentNip11(
relayUrl: "ws://relay.nostr.dev",
);
Implementation
@override
Future<RelayInformations> relayInformationsDocumentNip11({
required String relayUrl,
}) async {
try {
final relayHttpUri =
NostrWebSocketsService.instance.getHttpUrlFromWebSocketUrl(relayUrl);
final res = await http.get(
relayHttpUri,
headers: {
"Accept": "application/nostr+json",
},
);
final decoded = jsonDecode(res.body) as Map<String, dynamic>;
return RelayInformations.fromNip11Response(decoded);
} catch (e) {
NostrClientUtils.log(
"error while getting relay informations from nip11 for relay url: $relayUrl",
e,
);
rethrow;
}
}