url_set_for_ndk 0.1.0
url_set_for_ndk: ^0.1.0 copied to clipboard
Relay and Blossom server sets for the ndk package, described rather than listed so they can be persisted offline and resolved later from the NIP-65, NIP-17, NIP-37 and BUD-03 lists accounts publish.
example/url_set_for_ndk_example.dart
import 'package:ndk/ndk.dart';
import 'package:url_set_for_ndk/url_set_for_ndk.dart';
Future<void> main() async {
final ndk = Ndk(
NdkConfig(eventVerifier: Bip340EventVerifier(), cache: MemCacheManager()),
);
const pubkey =
'82341f882b6eabcd2ba7f1ef90aad961cf074af15b9ef44a09f9d2a8fbfbe6a2';
final servers = UrlSet.fallback([
UrlSet.blossom(pubkey),
UrlSet.explicit(['https://blossom.primal.net']),
]);
// Store this map in a queue record, resolve it later.
final stored = servers.toMap();
final resolution = await resolveUrlSet(
UrlSet.fromMap(stored),
ndkUrlListFn(ndk),
);
switch (resolution) {
case UrlsResolved(:final urls):
print('upload to $urls');
case UrlsUnavailable(:final reason):
print('try again later: $reason');
}
await ndk.destroy();
}