Nip65.fromEvent constructor

Nip65.fromEvent(
  1. Nip01Event event
)

Implementation

Nip65.fromEvent(Nip01Event event) {
  pubKey = event.pubKey;
  createdAt = event.createdAt;
  for (var tag in event.tags) {
    final length = tag.length;
    if (length <= 1) continue;
    final name = tag[0];

    // clean the url so it can be used as a unique identifier
    var cleanUrl = cleanRelayUrl(tag[1]);
    if (cleanUrl == null) continue;

    final url = cleanUrl;
    if (name != "r") continue;
    ReadWriteMarker? marker = ReadWriteMarker.readWrite;
    if (length > 2) {
      var operType = tag[2];
      switch (operType) {
        case "read":
          marker = ReadWriteMarker.readOnly;
          break;
        case "write":
          marker = ReadWriteMarker.writeOnly;
          break;
      }
    }
    relays[url] = marker;
  }
}