fromEvent static method

Future<Nip51List> fromEvent(
  1. Nip01Event event,
  2. EventSigner? signer
)

Implementation

static Future<Nip51List> fromEvent(
    Nip01Event event, EventSigner? signer) async {
  // if (event.kind == Nip51List.SEARCH_RELAYS || event.kind == Nip51List.BLOCKED_RELAYS) {
  //   privateRelays = [];
  //   publicRelays = [];
  // }
  Nip51List list = Nip51List(
      pubKey: event.pubKey,
      kind: event.kind,
      createdAt: event.createdAt,
      elements: []);
  list.id = event.id;

  list.parseTags(event.tags, private: false);

  if (Helpers.isNotBlank(event.content) &&
      signer != null &&
      signer.canSign()) {
    try {
      var json = await signer.decrypt(event.content, signer.getPublicKey());
      List<dynamic> tags = jsonDecode(json ?? '');
      list.parseTags(tags, private: true);
    } catch (e) {
      Logger.log.d(e);
    }
  }
  return list;
}